[Webkit-unassigned] [Bug 36849] Add zero() method to Vector class

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Mar 31 23:45:58 PDT 2010


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


Maciej Stachowiak <mjs at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mjs at apple.com




--- Comment #16 from Maciej Stachowiak <mjs at apple.com>  2010-03-31 23:45:57 PST ---
(In reply to comment #10)
> What about something like either of these.
> 
> 
> 
> namespace WTF {
> 
> template <bool canZero, typename T>
> struct ZeroFiller;
> 
> template<typename T>
> struct ZeroFiller<true, T> {
>     static void zero(T* begin, T* end)
>     {
>         memset(begin, 0, reinterpret_cast<char*>(end) -
> reinterpret_cast<char*>(begin));
>     }
> };
> 
> template<typename T>
> void zeroFill(T* begin, T* end)
> {
>     ZeroFiller::zero<IsPod<T>::value, T>(first, last)
> }
> 
> } // namespace WTF

1) How about implementing the non-POD version with a loop that just assigns 0?
That will still fail at compile time if the type pointed to is one where you
can't assign 0.

2) Is there any evidence that zeroFill() would measurably improve performance
over fill(0)?

Regards,
Maciej

-- 
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