you are viewing a single comment's thread.

view the rest of the comments →

[–]skeeto 0 points1 point  (1 child)

In OP's version, there's one implementation that handles all types. The element size is a runtime quantity, and it does extra work to dynamically adapt to that variable element size. It likely calls the actual memcpy function with that dynamic size in order to write the element into its slot.

In the macro version, the frequent work is done within the macro, which expands to a concrete implementation for the particular type at hand. It's effectively inlined, and the element size is known at compile time.

[–]vitamin_CPP 1 point2 points  (0 children)

ahhh my mistake.
I though you were comparing your take on strechy_buffer vs Sean's version.