OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 bool is_finalized() const { return position_ < 0; } | 520 bool is_finalized() const { return position_ < 0; } |
521 | 521 |
522 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 522 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); |
523 }; | 523 }; |
524 | 524 |
525 | 525 |
526 // Copy from ASCII/16bit chars to ASCII/16bit chars. | 526 // Copy from ASCII/16bit chars to ASCII/16bit chars. |
527 template <typename sourcechar, typename sinkchar> | 527 template <typename sourcechar, typename sinkchar> |
528 static inline void CopyChars(sinkchar* dest, const sourcechar* src, int chars) { | 528 static inline void CopyChars(sinkchar* dest, const sourcechar* src, int chars) { |
529 sinkchar* limit = dest + chars; | 529 sinkchar* limit = dest + chars; |
530 #ifdef CAN_READ_UNALIGNED | 530 #ifdef V8_HOST_CAN_READ_UNALIGNED |
531 if (sizeof(*dest) == sizeof(*src)) { | 531 if (sizeof(*dest) == sizeof(*src)) { |
532 // Number of characters in a uint32_t. | 532 // Number of characters in a uint32_t. |
533 static const int kStepSize = sizeof(uint32_t) / sizeof(*dest); // NOLINT | 533 static const int kStepSize = sizeof(uint32_t) / sizeof(*dest); // NOLINT |
534 while (dest <= limit - kStepSize) { | 534 while (dest <= limit - kStepSize) { |
535 *reinterpret_cast<uint32_t*>(dest) = | 535 *reinterpret_cast<uint32_t*>(dest) = |
536 *reinterpret_cast<const uint32_t*>(src); | 536 *reinterpret_cast<const uint32_t*>(src); |
537 dest += kStepSize; | 537 dest += kStepSize; |
538 src += kStepSize; | 538 src += kStepSize; |
539 } | 539 } |
540 } | 540 } |
541 #endif | 541 #endif |
542 while (dest < limit) { | 542 while (dest < limit) { |
543 *dest++ = static_cast<sinkchar>(*src++); | 543 *dest++ = static_cast<sinkchar>(*src++); |
544 } | 544 } |
545 } | 545 } |
546 | 546 |
547 | 547 |
548 } } // namespace v8::internal | 548 } } // namespace v8::internal |
549 | 549 |
550 #endif // V8_UTILS_H_ | 550 #endif // V8_UTILS_H_ |
OLD | NEW |