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

Unified Diff: src/heap-inl.h

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.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698