Commit 556a8975 authored by Milo Yip's avatar Milo Yip

Add RAPIDJSON_UNLIKELY in Value::Accept()

parent b5156274
......@@ -1535,22 +1535,22 @@ public:
case kTrueType: return handler.Bool(true);
case kObjectType:
if (!handler.StartObject())
if (RAPIDJSON_UNLIKELY(!handler.StartObject()))
return false;
for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++m) {
RAPIDJSON_ASSERT(m->name.IsString()); // User may change the type of name by MemberIterator.
if (!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.flags_ & kCopyFlag) != 0))
if (RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.flags_ & kCopyFlag) != 0)))
return false;
if (!m->value.Accept(handler))
if (RAPIDJSON_UNLIKELY(!m->value.Accept(handler)))
return false;
}
return handler.EndObject(data_.o.size);
case kArrayType:
if (!handler.StartArray())
if (RAPIDJSON_UNLIKELY(!handler.StartArray()))
return false;
for (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)
if (!v->Accept(handler))
for (const GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)
if (RAPIDJSON_UNLIKELY(!v->Accept(handler)))
return false;
return handler.EndArray(data_.a.size);
......@@ -1559,11 +1559,11 @@ public:
default:
RAPIDJSON_ASSERT(GetType() == kNumberType);
if (IsInt()) return handler.Int(data_.n.i.i);
if (IsDouble()) return handler.Double(data_.n.d);
else if (IsInt()) return handler.Int(data_.n.i.i);
else if (IsUint()) return handler.Uint(data_.n.u.u);
else if (IsInt64()) return handler.Int64(data_.n.i64);
else if (IsUint64()) return handler.Uint64(data_.n.u64);
else return handler.Double(data_.n.d);
else return handler.Uint64(data_.n.u64);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment