Author: [EMAIL PROTECTED]
Date: Thu Oct 23 00:20:28 2008
New Revision: 562
Modified:
branches/bleeding_edge/src/utils.h
Log:
Copy strings 1 word at a time when flattening etc.
Review URL: http://codereview.chromium.org/7885
Modified: branches/bleeding_edge/src/utils.h
==============================================================================
--- branches/bleeding_edge/src/utils.h (original)
+++ branches/bleeding_edge/src/utils.h Thu Oct 23 00:20:28 2008
@@ -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
-~----------~----~----~----~------~----~------~--~---