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

Unified Diff: src/heap.cc

Issue 6072004: Avoid decoding overhead when allocating ascii strings.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | src/heap-inl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 6096)
+++ src/heap.cc (working copy)
@@ -3307,8 +3307,8 @@
}
-MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> string,
- PretenureFlag pretenure) {
+MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string,
+ PretenureFlag pretenure) {
// V8 only supports characters in the Basic Multilingual Plane.
const uc32 kMaxSupportedChar = 0xFFFF;
// Count the number of characters in the UTF-8 string and check if
@@ -3317,17 +3317,11 @@
decoder(ScannerConstants::utf8_decoder());
decoder->Reset(string.start(), string.length());
int chars = 0;
- bool is_ascii = true;
while (decoder->has_more()) {
- uc32 r = decoder->GetNext();
- if (r > String::kMaxAsciiCharCode) is_ascii = false;
+ decoder->GetNext();
chars++;
}
- // If the string is ascii, we do not need to convert the characters
- // since UTF8 is backwards compatible with ascii.
- if (is_ascii) return AllocateStringFromAscii(string, pretenure);
-
Object* result;
{ MaybeObject* maybe_result = AllocateRawTwoByteString(chars, pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | src/heap-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698