Index: src/heap-inl.h |
=================================================================== |
--- src/heap-inl.h (revision 6096) |
+++ src/heap-inl.h (working copy) |
@@ -40,6 +40,21 @@ |
} |
+MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, |
+ PretenureFlag pretenure) { |
+ // Check for ascii first since this is the common case. |
Lasse Reichstein
2010/12/21 12:48:12
ASCII is an acronym, even though we might not resp
Mads Ager (chromium)
2010/12/21 12:55:52
Done.
|
+ for (int i = 0; i < str.length(); ++i) { |
+ if (static_cast<uc16>(str[i]) > String::kMaxAsciiCharCode) { |
Lasse Reichstein
2010/12/21 12:48:12
Just cast to uint8_t, and compare to String:kMaxAs
Mads Ager (chromium)
2010/12/21 12:55:52
Done.
|
+ // Non-ascii and we need to decode. |
+ return AllocateStringFromUtf8Slow(str, pretenure); |
+ } |
+ } |
+ // If the string is ascii, we do not need to convert the characters |
+ // since UTF8 is backwards compatible with ascii. |
+ return AllocateStringFromAscii(str, pretenure); |
+} |
+ |
+ |
MaybeObject* Heap::AllocateSymbol(Vector<const char> str, |
int chars, |
uint32_t hash_field) { |