Skip to content

Commit 0554ae3

Browse files
committed
Removed unnecessary overhead from Object::copy().
The shared_ptr machinery has a pretty significant overhead when copying small objects - this change gives almost a 50% reduction in runtime in a benchmark which copies many small data objects (where lazy-copy-on-write defers most of the real work anyway). There were a few unecessary overheads : - Allocating the CopyContext on the heap. - Using a shared_ptr - Allocates another heap object for use as a reference count. - Uses atomic operations to increment and decrement the reference count.
1 parent 16debfd commit 0554ae3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/IECore/Object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ size_t Object::MemoryAccumulator::total() const
312312

313313
ObjectPtr Object::copy() const
314314
{
315-
boost::shared_ptr<CopyContext> c( new CopyContext );
316-
ObjectPtr result = c->copy( this );
315+
CopyContext c;
316+
ObjectPtr result = c.copy( this );
317317
return result;
318318
}
319319

0 commit comments

Comments
 (0)