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

Unified Diff: src/json-stringifier.h

Issue 736543003: Use FlatStringReader in JSON stringifier. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698