Index: src/json-stringifier.h |
diff --git a/src/json-stringifier.h b/src/json-stringifier.h |
index e6f5cfde105966e4dbc7df8ffd06df4abea00714..f89a19fd4a9b06abf2b1dd4e17a86ef09d38cdd0 100644 |
--- a/src/json-stringifier.h |
+++ b/src/json-stringifier.h |
@@ -38,22 +38,22 @@ class BasicJsonStringifier BASE_EMBEDDED { |
INLINE(void ShrinkCurrentPart()); |
- template <bool is_ascii, typename Char> |
+ template <bool is_one_byte, typename Char> |
INLINE(void Append_(Char c)); |
- template <bool is_ascii, typename Char> |
+ template <bool is_one_byte, typename Char> |
INLINE(void Append_(const Char* chars)); |
INLINE(void Append(uint8_t c)) { |
- if (is_ascii_) { |
+ if (is_one_byte_) { |
Append_<true>(c); |
} else { |
Append_<false>(c); |
} |
} |
- INLINE(void AppendAscii(const char* chars)) { |
- if (is_ascii_) { |
+ INLINE(void AppendOneByte(const char* chars)) { |
+ if (is_one_byte_) { |
Append_<true>(reinterpret_cast<const uint8_t*>(chars)); |
} else { |
Append_<false>(reinterpret_cast<const uint8_t*>(chars)); |
@@ -129,7 +129,7 @@ class BasicJsonStringifier BASE_EMBEDDED { |
DestChar* dest, |
int length)); |
- template <bool is_ascii, typename Char> |
+ template <bool is_one_byte, typename Char> |
INLINE(void SerializeString_(Handle<String> string)); |
template <typename Char> |
@@ -159,7 +159,7 @@ class BasicJsonStringifier BASE_EMBEDDED { |
Handle<JSArray> stack_; |
int current_index_; |
int part_length_; |
- bool is_ascii_; |
+ bool is_one_byte_; |
bool overflowed_; |
static const int kJsonEscapeTableEntrySize = 8; |
@@ -167,7 +167,7 @@ class BasicJsonStringifier BASE_EMBEDDED { |
}; |
-// Translation table to escape ASCII characters. |
+// Translation table to escape Latin1 characters. |
// Table entries start at a multiple of 8 and are null-terminated. |
const char* const BasicJsonStringifier::JsonEscapeTable = |
"\\u0000\0 \\u0001\0 \\u0002\0 \\u0003\0 " |
@@ -239,7 +239,7 @@ const char* const BasicJsonStringifier::JsonEscapeTable = |
BasicJsonStringifier::BasicJsonStringifier(Isolate* isolate) |
: isolate_(isolate), |
current_index_(0), |
- is_ascii_(true), |
+ is_one_byte_(true), |
overflowed_(false) { |
factory_ = isolate_->factory(); |
accumulator_store_ = Handle<JSValue>::cast( |
@@ -317,9 +317,9 @@ Handle<String> BasicJsonStringifier::StringifyString_(Isolate* isolate, |
} |
-template <bool is_ascii, typename Char> |
+template <bool is_one_byte, typename Char> |
void BasicJsonStringifier::Append_(Char c) { |
- if (is_ascii) { |
+ if (is_one_byte) { |
SeqOneByteString::cast(*current_part_)->SeqOneByteStringSet( |
current_index_++, c); |
} else { |
@@ -330,9 +330,9 @@ void BasicJsonStringifier::Append_(Char c) { |
} |
-template <bool is_ascii, typename Char> |
+template <bool is_one_byte, typename Char> |
void BasicJsonStringifier::Append_(const Char* chars) { |
- for ( ; *chars != '\0'; chars++) Append_<is_ascii, Char>(*chars); |
+ for (; *chars != '\0'; chars++) Append_<is_one_byte, Char>(*chars); |
} |
@@ -416,15 +416,15 @@ BasicJsonStringifier::Result BasicJsonStringifier::Serialize_( |
switch (Oddball::cast(*object)->kind()) { |
case Oddball::kFalse: |
if (deferred_string_key) SerializeDeferredKey(comma, key); |
- AppendAscii("false"); |
+ AppendOneByte("false"); |
return SUCCESS; |
case Oddball::kTrue: |
if (deferred_string_key) SerializeDeferredKey(comma, key); |
- AppendAscii("true"); |
+ AppendOneByte("true"); |
return SUCCESS; |
case Oddball::kNull: |
if (deferred_string_key) SerializeDeferredKey(comma, key); |
- AppendAscii("null"); |
+ AppendOneByte("null"); |
return SUCCESS; |
default: |
return UNCHANGED; |
@@ -511,7 +511,7 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue( |
DCHECK(class_name == isolate_->heap()->Boolean_string()); |
Object* value = JSValue::cast(*object)->value(); |
DCHECK(value->IsBoolean()); |
- AppendAscii(value->IsTrue() ? "true" : "false"); |
+ AppendOneByte(value->IsTrue() ? "true" : "false"); |
} |
return SUCCESS; |
} |
@@ -521,7 +521,7 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeSmi(Smi* object) { |
static const int kBufferSize = 100; |
char chars[kBufferSize]; |
Vector<char> buffer(chars, kBufferSize); |
- AppendAscii(IntToCString(object->value(), buffer)); |
+ AppendOneByte(IntToCString(object->value(), buffer)); |
return SUCCESS; |
} |
@@ -529,13 +529,13 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeSmi(Smi* object) { |
BasicJsonStringifier::Result BasicJsonStringifier::SerializeDouble( |
double number) { |
if (std::isinf(number) || std::isnan(number)) { |
- AppendAscii("null"); |
+ AppendOneByte("null"); |
return SUCCESS; |
} |
static const int kBufferSize = 100; |
char chars[kBufferSize]; |
Vector<char> buffer(chars, kBufferSize); |
- AppendAscii(DoubleToCString(number, buffer)); |
+ AppendOneByte(DoubleToCString(number, buffer)); |
return SUCCESS; |
} |
@@ -580,7 +580,7 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSArray( |
i); |
if (result == SUCCESS) continue; |
if (result == UNCHANGED) { |
- AppendAscii("null"); |
+ AppendOneByte("null"); |
} else { |
return result; |
} |
@@ -613,12 +613,12 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSArraySlow( |
Object::GetElement(isolate_, object, i), |
EXCEPTION); |
if (element->IsUndefined()) { |
- AppendAscii("null"); |
+ AppendOneByte("null"); |
} else { |
Result result = SerializeElement(isolate_, element, i); |
if (result == SUCCESS) continue; |
if (result == UNCHANGED) { |
- AppendAscii("null"); |
+ AppendOneByte("null"); |
} else { |
return result; |
} |
@@ -731,7 +731,7 @@ void BasicJsonStringifier::Extend() { |
if (part_length_ <= kMaxPartLength / kPartLengthGrowthFactor) { |
part_length_ *= kPartLengthGrowthFactor; |
} |
- if (is_ascii_) { |
+ if (is_one_byte_) { |
current_part_ = |
factory_->NewRawOneByteString(part_length_).ToHandleChecked(); |
} else { |
@@ -750,7 +750,7 @@ void BasicJsonStringifier::ChangeEncoding() { |
factory_->NewRawTwoByteString(part_length_).ToHandleChecked(); |
DCHECK(!current_part_.is_null()); |
current_index_ = 0; |
- is_ascii_ = false; |
+ is_one_byte_ = false; |
} |
@@ -779,10 +779,10 @@ int BasicJsonStringifier::SerializeStringUnchecked_(const SrcChar* src, |
} |
-template <bool is_ascii, typename Char> |
+template <bool is_one_byte, typename Char> |
void BasicJsonStringifier::SerializeString_(Handle<String> string) { |
int length = string->length(); |
- Append_<is_ascii, char>('"'); |
+ Append_<is_one_byte, 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 |
// an escaped character is 6. Shifting the remainin string length right by 3 |
@@ -791,7 +791,7 @@ void BasicJsonStringifier::SerializeString_(Handle<String> string) { |
if (((part_length_ - current_index_) >> 3) > length) { |
DisallowHeapAllocation no_gc; |
Vector<const Char> vector = GetCharVector<Char>(string); |
- if (is_ascii) { |
+ if (is_one_byte) { |
current_index_ += SerializeStringUnchecked_( |
vector.start(), |
SeqOneByteString::cast(*current_part_)->GetChars() + current_index_, |
@@ -815,15 +815,15 @@ void BasicJsonStringifier::SerializeString_(Handle<String> string) { |
} |
Char c = vector[i]; |
if (DoNotEscape(c)) { |
- Append_<is_ascii, Char>(c); |
+ Append_<is_one_byte, Char>(c); |
} else { |
- Append_<is_ascii, uint8_t>(reinterpret_cast<const uint8_t*>( |
+ Append_<is_one_byte, uint8_t>(reinterpret_cast<const uint8_t*>( |
&JsonEscapeTable[c * kJsonEscapeTableEntrySize])); |
} |
} |
} |
- Append_<is_ascii, uint8_t>('"'); |
+ Append_<is_one_byte, uint8_t>('"'); |
} |
@@ -843,7 +843,7 @@ template <> |
Vector<const uint8_t> BasicJsonStringifier::GetCharVector( |
Handle<String> string) { |
String::FlatContent flat = string->GetFlatContent(); |
- DCHECK(flat.IsAscii()); |
+ DCHECK(flat.IsOneByte()); |
return flat.ToOneByteVector(); |
} |
@@ -858,7 +858,7 @@ Vector<const uc16> BasicJsonStringifier::GetCharVector(Handle<String> string) { |
void BasicJsonStringifier::SerializeString(Handle<String> object) { |
object = String::Flatten(object); |
- if (is_ascii_) { |
+ if (is_one_byte_) { |
if (object->IsOneByteRepresentationUnderneath()) { |
SerializeString_<true, uint8_t>(object); |
} else { |