Index: src/heap-inl.h |
diff --git a/src/heap-inl.h b/src/heap-inl.h |
index a7645e25f1ebf512c306dc6120f5b179f5a3dc01..bace902d4dce87cc3b33c242e774c713acc08a27 100644 |
--- a/src/heap-inl.h |
+++ b/src/heap-inl.h |
@@ -85,13 +85,16 @@ void PromotionQueue::ActivateGuardIfOnTheSamePage() { |
MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, |
PretenureFlag pretenure) { |
// Check for ASCII first since this is the common case. |
- if (String::IsAscii(str.start(), str.length())) { |
+ const char* start = str.start(); |
+ int length = str.length(); |
+ int non_ascii_start = String::NonAsciiStart(start, length); |
+ if (non_ascii_start >= length) { |
// If the string is ASCII, we do not need to convert the characters |
// since UTF8 is backwards compatible with ASCII. |
return AllocateStringFromAscii(str, pretenure); |
} |
// Non-ASCII and we need to decode. |
- return AllocateStringFromUtf8Slow(str, pretenure); |
+ return AllocateStringFromUtf8Slow(str, non_ascii_start, pretenure); |
} |