Reviewers: Igor Sheludko,

Description:
Use FlatStringReader in JSON stringifier.

[email protected]

Please review this at https://codereview.chromium.org/736543003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+3, -11 lines):
  M src/json-stringifier.h


Index: src/json-stringifier.h
diff --git a/src/json-stringifier.h b/src/json-stringifier.h
index d28883fc5d36e443963e18ef422303bf3b742e97..4cdf31e45696f08f0a90c4fc31cc26948c09ff72 100644
--- a/src/json-stringifier.h
+++ b/src/json-stringifier.h
@@ -639,17 +639,9 @@ void BasicJsonStringifier::SerializeString_(Handle<String> string) {
         &builder_, worst_case_length);
     SerializeStringUnchecked_(vector, &no_extend);
   } else {
-    String* string_location = NULL;
-    Vector<const SrcChar> vector(NULL, 0);
-    for (int i = 0; i < length; i++) {
-      // If GC moved the string, we need to refresh the vector.
-      if (*string != string_location) {
-        DisallowHeapAllocation no_gc;
- // This does not actually prevent the string from being relocated later.
-        vector = GetCharVector<SrcChar>(string);
-        string_location = *string;
-      }
-      SrcChar c = vector[i];
+    FlatStringReader reader(isolate_, string);
+    for (int i = 0; i < reader.length(); i++) {
+      SrcChar c = static_cast<SrcChar>(reader.Get(i));
       if (DoNotEscape(c)) {
         builder_.Append<SrcChar, DestChar>(c);
       } else {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to