Chromium Code Reviews| Index: src/heap.cc |
| diff --git a/src/heap.cc b/src/heap.cc |
| index 4fd1a041eabfc73b4fa6ed112c0970447e163c06..afbc192b161c8384d7f14bb844c2da71bfcc99e1 100644 |
| --- a/src/heap.cc |
| +++ b/src/heap.cc |
| @@ -4428,13 +4428,14 @@ MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string, |
| MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string, |
| + const char* non_ascii_start, |
|
Yang
2012/10/18 14:46:23
Maybe it's cleaner to pass non_ascii_start as stri
Toon Verwaest
2012/10/18 15:06:56
Done.
|
| PretenureFlag pretenure) { |
| - // Count the number of characters in the UTF-8 string and check if |
| - // it is an ASCII string. |
| + // Continue counting the number of characters in the UTF-8 string, starting |
| + // from the first non-ascii character or word. |
| + int chars = non_ascii_start - string.start(); |
| Access<UnicodeCache::Utf8Decoder> |
| decoder(isolate_->unicode_cache()->utf8_decoder()); |
| - decoder->Reset(string.start(), string.length()); |
| - int chars = 0; |
| + decoder->Reset(non_ascii_start, string.length() - chars); |
| while (decoder->has_more()) { |
| uint32_t r = decoder->GetNext(); |
| if (r <= unibrow::Utf16::kMaxNonSurrogateCharCode) { |