Bug 560349 - make PodZero use inline loops rather than memset; r=luke

This commit is contained in:
Nathan Froyd 2011-12-08 19:59:08 -05:00
parent 1513850d8f
commit f5918cd8f9

View File

@ -280,7 +280,14 @@ template <class T>
JS_ALWAYS_INLINE static void
PodZero(T *t, size_t nelem)
{
memset(t, 0, nelem * sizeof(T));
/*
* This function is often called with 'nelem' small; we use an
* inline loop instead of calling 'memset' with a non-constant
* length. The compiler should inline the memset call with constant
* size, though.
*/
for (size_t i = 0; i < nelem; ++i, ++t)
memset(t, 0, sizeof(T));
}
/*