| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_JSON_STRINGIFIER_H_ | 5 #ifndef V8_JSON_STRINGIFIER_H_ |
| 6 #define V8_JSON_STRINGIFIER_H_ | 6 #define V8_JSON_STRINGIFIER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 int worst_case_length = length << 3; | 634 int worst_case_length = length << 3; |
| 635 if (builder_.CurrentPartCanFit(worst_case_length)) { | 635 if (builder_.CurrentPartCanFit(worst_case_length)) { |
| 636 DisallowHeapAllocation no_gc; | 636 DisallowHeapAllocation no_gc; |
| 637 Vector<const SrcChar> vector = GetCharVector<SrcChar>(string); | 637 Vector<const SrcChar> vector = GetCharVector<SrcChar>(string); |
| 638 IncrementalStringBuilder::NoExtendBuilder<DestChar> no_extend( | 638 IncrementalStringBuilder::NoExtendBuilder<DestChar> no_extend( |
| 639 &builder_, worst_case_length); | 639 &builder_, worst_case_length); |
| 640 SerializeStringUnchecked_(vector, &no_extend); | 640 SerializeStringUnchecked_(vector, &no_extend); |
| 641 } else { | 641 } else { |
| 642 FlatStringReader reader(isolate_, string); | 642 FlatStringReader reader(isolate_, string); |
| 643 for (int i = 0; i < reader.length(); i++) { | 643 for (int i = 0; i < reader.length(); i++) { |
| 644 SrcChar c = static_cast<SrcChar>(reader.Get(i)); | 644 SrcChar c = reader.Get<SrcChar>(i); |
| 645 if (DoNotEscape(c)) { | 645 if (DoNotEscape(c)) { |
| 646 builder_.Append<SrcChar, DestChar>(c); | 646 builder_.Append<SrcChar, DestChar>(c); |
| 647 } else { | 647 } else { |
| 648 builder_.AppendCString(&JsonEscapeTable[c * kJsonEscapeTableEntrySize]); | 648 builder_.AppendCString(&JsonEscapeTable[c * kJsonEscapeTableEntrySize]); |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 | 652 |
| 653 builder_.Append<uint8_t, DestChar>('"'); | 653 builder_.Append<uint8_t, DestChar>('"'); |
| 654 } | 654 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 SerializeString_<uint8_t, uc16>(object); | 697 SerializeString_<uint8_t, uc16>(object); |
| 698 } else { | 698 } else { |
| 699 SerializeString_<uc16, uc16>(object); | 699 SerializeString_<uc16, uc16>(object); |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 | 703 |
| 704 } } // namespace v8::internal | 704 } } // namespace v8::internal |
| 705 | 705 |
| 706 #endif // V8_JSON_STRINGIFIER_H_ | 706 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |