| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 SrcChar c = src[i]; | 580 SrcChar c = src[i]; |
| 581 if (DoNotEscape(c)) { | 581 if (DoNotEscape(c)) { |
| 582 *(dest++) = static_cast<DestChar>(c); | 582 *(dest++) = static_cast<DestChar>(c); |
| 583 } else { | 583 } else { |
| 584 const char* chars = &JsonEscapeTable[c * kJsonEscapeTableEntrySize]; | 584 const char* chars = &JsonEscapeTable[c * kJsonEscapeTableEntrySize]; |
| 585 while (*chars != '\0') *(dest++) = *(chars++); | 585 while (*chars != '\0') *(dest++) = *(chars++); |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 | 588 |
| 589 *(dest++) = '"'; | 589 *(dest++) = '"'; |
| 590 current_index_ += dest - dest_start; | 590 current_index_ += static_cast<int>(dest - dest_start); |
| 591 } | 591 } |
| 592 | 592 |
| 593 | 593 |
| 594 template <bool is_ascii, typename Char> | 594 template <bool is_ascii, typename Char> |
| 595 void BasicJsonStringifier::SerializeString_(Vector<const Char> vector, | 595 void BasicJsonStringifier::SerializeString_(Vector<const Char> vector, |
| 596 Handle<String> string) { | 596 Handle<String> string) { |
| 597 int length = vector.length(); | 597 int length = vector.length(); |
| 598 // We make a rough estimate to find out if the current string can be | 598 // We make a rough estimate to find out if the current string can be |
| 599 // serialized without allocating a new string part. The worst case length of | 599 // serialized without allocating a new string part. The worst case length of |
| 600 // an escaped character is 6. Shifting left by 3 is a more pessimistic | 600 // an escaped character is 6. Shifting left by 3 is a more pessimistic |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 SerializeString_<false, char>(flat.ToAsciiVector(), object); | 677 SerializeString_<false, char>(flat.ToAsciiVector(), object); |
| 678 } else { | 678 } else { |
| 679 SerializeString_<false, uc16>(flat.ToUC16Vector(), object); | 679 SerializeString_<false, uc16>(flat.ToUC16Vector(), object); |
| 680 } | 680 } |
| 681 } | 681 } |
| 682 } | 682 } |
| 683 | 683 |
| 684 } } // namespace v8::internal | 684 } } // namespace v8::internal |
| 685 | 685 |
| 686 #endif // V8_JSON_STRINGIFIER_H_ | 686 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |