| 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);
|
| }
|
| }
|
| }
|
|
|