Reviewers: plesner, Description: Copy strings 1 word at a time when flattening etc.
Please review this at http://codereview.chromium.org/7885 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/utils.h Index: src/utils.h =================================================================== --- src/utils.h (revision 554) +++ src/utils.h (working copy) @@ -447,7 +447,20 @@ // Copy from ASCII/16bit chars to ASCII/16bit chars. template <typename sourcechar, typename sinkchar> static inline void CopyChars(sinkchar* dest, const sourcechar* src, int chars) { - while (chars--) { + sinkchar* limit = dest + chars; +#ifdef CAN_READ_UNALIGNED + if (sizeof(*dest) == sizeof(*src)) { + // Number of characters in a uint32_t. + static const int kStepSize = sizeof(uint32_t) / sizeof(*dest); // NOLINT + while (dest <= limit - kStepSize) { + *reinterpret_cast<uint32_t*>(dest) = + *reinterpret_cast<const uint32_t*>(src); + dest += kStepSize; + src += kStepSize; + } + } +#endif + while (dest < limit) { *dest++ = static_cast<sinkchar>(*src++); } } --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
