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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 bool is_finalized() const { return position_ < 0; } | 441 bool is_finalized() const { return position_ < 0; } |
442 | 442 |
443 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 443 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); |
444 }; | 444 }; |
445 | 445 |
446 | 446 |
447 // Copy from ASCII/16bit chars to ASCII/16bit chars. | 447 // Copy from ASCII/16bit chars to ASCII/16bit chars. |
448 template <typename sourcechar, typename sinkchar> | 448 template <typename sourcechar, typename sinkchar> |
449 static inline void CopyChars(sinkchar* dest, const sourcechar* src, int chars) { | 449 static inline void CopyChars(sinkchar* dest, const sourcechar* src, int chars) { |
450 while (chars--) { | 450 while (chars--) { |
451 *dest++ = *src++; | 451 // We have to have a cast here, otherwise MSVC complains about a possible |
| 452 // loss of data when sourcechar is 16 bit and sinkchar is 8 bit. But we |
| 453 // can't have a reinterpret cast because gcc doesn't like a reinterpret_cast |
| 454 // that doesn't change the type. |
| 455 *dest++ = (sinkchar)(*src++); |
452 } | 456 } |
453 } | 457 } |
454 | 458 |
455 } } // namespace v8::internal | 459 } } // namespace v8::internal |
456 | 460 |
457 #endif // V8_UTILS_H_ | 461 #endif // V8_UTILS_H_ |
OLD | NEW |