[Webkit-unassigned] [Bug 94810] Vector::shrinkToFit should use realloc when canCopyWithMemcpy is true

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 29 07:47:09 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=94810





--- Comment #24 from Yong Li <yoli at rim.com>  2012-08-29 07:47:11 PST ---
(In reply to comment #23)
> (From update of attachment 161042 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=161042&action=review
> I'll have to double check the VectorTraits<T>::canMoveWithMemcpy, I do not remember by heart if it is the right one.

If I understand correctly, this is for the objects with something like ref-counter. For example, RefPtr<T> cannot be C++-copied with memcpy, as creating a copy should increase the ref-count, but memcpy doesn't do that. However, it can be moved with memcpy as it is nothing but a pointer to the RefCounted object.

> 10 times faster!!! I should really try your bench with fastMalloc!

That is only for large blocks. And it is reasonable because it just releases the free space to system in this case, so it takes no time compared to allocating a new block, memcpying, and freeing the old block.

Thanks a lot for reviewing and all the suggestions!

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list