Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
r12761 committed - Adding a fast path for parsing index keys....
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
codesite-nore...@google.com  
View profile  
 More options Oct 18 2012, 10:45 am
From: codesite-nore...@google.com
Date: Thu, 18 Oct 2012 14:45:11 +0000
Local: Thurs, Oct 18 2012 10:45 am
Subject: [v8] r12761 committed - Adding a fast path for parsing index keys....
Revision: 12761
Author:   verwa...@chromium.org
Date:     Thu Oct 18 07:44:40 2012
Log:      Adding a fast path for parsing index keys.

Reduces overhead on  
http://code.google.com/p/chromium/issues/detail?id=156379 from 360ms down  
to 255ms.

Review URL: https://chromiumcodereview.appspot.com/11189039
http://code.google.com/p/v8/source/detail?r=12761

Modified:
  /branches/bleeding_edge/src/json-parser.h

=======================================
--- /branches/bleeding_edge/src/json-parser.h   Thu Oct 18 06:15:05 2012
+++ /branches/bleeding_edge/src/json-parser.h   Thu Oct 18 07:44:40 2012
@@ -301,23 +301,49 @@
    if (c0_ != '}') {
      do {
        if (c0_ != '"') return ReportUnexpectedCharacter();
-      Handle<String> key = ParseJsonSymbol();
-      if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter();
-      AdvanceSkipWhitespace();
-      Handle<Object> value = ParseJsonValue();
-      if (value.is_null()) return ReportUnexpectedCharacter();

-      uint32_t index;
-      if (key->AsArrayIndex(&index)) {
+      int start_position = position_;
+      Advance();
+
+      uint32_t index = 0;
+      while (c0_ >= '0' && c0_ <= '9') {
+        int d = c0_ - '0';
+        if (index > 429496729U - ((d > 5) ? 1 : 0)) break;
+        index = (index * 10) + d;
+        Advance();
+      }
+
+      if (position_ != start_position + 1 && c0_ == '"') {
+        AdvanceSkipWhitespace();
+
+        if (c0_ != ':') return ReportUnexpectedCharacter();
+        AdvanceSkipWhitespace();
+        Handle<Object> value = ParseJsonValue();
+        if (value.is_null()) return ReportUnexpectedCharacter();
+
          JSObject::SetOwnElement(json_object, index, value, kNonStrictMode);
-      } else if (key->Equals(isolate()->heap()->Proto_symbol())) {
-        prototype = value;
        } else {
-        if (JSObject::TryTransitionToField(json_object, key)) {
-          json_object->FastPropertyAtPut(current_index++, *value);
+        position_ = start_position;
+#ifdef DEBUG
+        c0_ = '"';
+#endif
+
+        Handle<String> key = ParseJsonSymbol();
+        if (key.is_null() || c0_ != ':') return  
ReportUnexpectedCharacter();
+
+        AdvanceSkipWhitespace();
+        Handle<Object> value = ParseJsonValue();
+        if (value.is_null()) return ReportUnexpectedCharacter();
+
+        if (key->Equals(isolate()->heap()->Proto_symbol())) {
+          prototype = value;
          } else {
-          JSObject::SetLocalPropertyIgnoreAttributes(
-              json_object, key, value, NONE);
+          if (JSObject::TryTransitionToField(json_object, key)) {
+            json_object->FastPropertyAtPut(current_index++, *value);
+          } else {
+            JSObject::SetLocalPropertyIgnoreAttributes(
+                json_object, key, value, NONE);
+          }
          }
        }
      } while (MatchSkipWhiteSpace(','));
@@ -374,14 +400,12 @@
      if ('0' <= c0_ && c0_ <= '9') return ReportUnexpectedCharacter();
    } else {
      int i = 0;
-    int digits = 0;
      if (c0_ < '1' || c0_ > '9') return ReportUnexpectedCharacter();
      do {
        i = i * 10 + c0_ - '0';
-      digits++;
        Advance();
-    } while (c0_ >= '0' && c0_ <= '9');
-    if (c0_ != '.' && c0_ != 'e' && c0_ != 'E' && digits < 10) {
+    } while (c0_ >= '0' && c0_ <= '9' && i <= (kMaxInt - 9) / 10);
+    if (c0_ != '.' && c0_ != 'e' && c0_ != 'E') {
        SkipWhitespace();
        return Handle<Smi>(Smi::FromInt((negative ? -i : i)), isolate());
      }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »