Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: src/heap-inl.h

Issue 5963003: Clean up is-ASCII checks. (Closed)
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index 62e810fcb1b80b44a2b518c1c8eb460abd68534c..26cf6e0f4751d0c5ea1c839339170ff0433e0bae 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -43,15 +43,13 @@ int Heap::MaxObjectSizeInPagedSpace() {
MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str,
PretenureFlag pretenure) {
// Check for ASCII first since this is the common case.
- for (int i = 0; i < str.length(); ++i) {
- if (static_cast<uint8_t>(str[i]) > String::kMaxAsciiCharCodeU) {
- // Non-ASCII and we need to decode.
- return AllocateStringFromUtf8Slow(str, pretenure);
- }
+ if (String::IsAscii(str.start(), str.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);
}
- // 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);
}
« src/heap.cc ('K') | « src/heap.cc ('k') | src/ia32/regexp-macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698