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

Unified Diff: src/json-stringifier.h

Issue 11421200: Fix JSON stringify. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « 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 80ef39507812207ac5dbaa690b51855bfd522793..09014f0d9d80f9ff2caa37180210ab7a6b450970 100644
--- a/src/json-stringifier.h
+++ b/src/json-stringifier.h
@@ -136,8 +136,7 @@ class BasicJsonStringifier BASE_EMBEDDED {
int length));
template <bool is_ascii, typename Char>
- INLINE(void SerializeString_(Vector<const Char> vector,
- Handle<String> string));
+ INLINE(void SerializeString_(Handle<String> string));
template <typename Char>
INLINE(bool DoNotEscape(Char c));
@@ -675,9 +674,8 @@ void BasicJsonStringifier::SerializeStringUnchecked_(const SrcChar* src,
template <bool is_ascii, typename Char>
-void BasicJsonStringifier::SerializeString_(Vector<const Char> vector,
- Handle<String> string) {
- int length = vector.length();
+void BasicJsonStringifier::SerializeString_(Handle<String> string) {
+ int length = string->length();
Append_<is_ascii, char>('"');
// We make a rough estimate to find out if the current string can be
// serialized without allocating a new string part. The worst case length of
@@ -685,6 +683,8 @@ void BasicJsonStringifier::SerializeString_(Vector<const Char> vector,
// is a more pessimistic estimate, but faster to calculate.
if (((part_length_ - current_index_) >> 3) > length) {
+ AssertNoAllocation no_allocation;
+ Vector<const Char> vector = GetCharVector<Char>(string);
if (is_ascii) {
SerializeStringUnchecked_(
vector.start(),
@@ -698,6 +698,7 @@ void BasicJsonStringifier::SerializeString_(Vector<const Char> vector,
}
} else {
String* string_location = *string;
+ Vector<const Char> vector = GetCharVector<Char>(string);
for (int i = 0; i < length; i++) {
Char c = vector[i];
if (DoNotEscape(c)) {
@@ -751,16 +752,16 @@ void BasicJsonStringifier::SerializeString(Handle<String> object) {
String::FlatContent flat = object->GetFlatContent();
if (is_ascii_) {
if (flat.IsAscii()) {
- SerializeString_<true, char>(flat.ToAsciiVector(), object);
+ SerializeString_<true, char>(object);
} else {
ChangeEncoding();
SerializeString(object);
}
} else {
if (flat.IsAscii()) {
- SerializeString_<false, char>(flat.ToAsciiVector(), object);
+ SerializeString_<false, char>(object);
} else {
- SerializeString_<false, uc16>(flat.ToUC16Vector(), object);
+ SerializeString_<false, uc16>(object);
}
}
}
« 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