mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-28 02:33:28 +02:00
Remove initInt and initUInt until they are needed.
This commit is contained in:
parent
9c80798038
commit
8eb5d89db6
@ -440,6 +440,8 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
size_t getOffsetLimit() const;
|
size_t getOffsetLimit() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initBasic(ValueType type, bool allocated = false);
|
||||||
|
|
||||||
Value& resolveReference(const char* key, bool isStatic);
|
Value& resolveReference(const char* key, bool isStatic);
|
||||||
|
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
@ -225,14 +225,8 @@ bool Value::CZString::isStaticString() const { return index_ == noDuplication; }
|
|||||||
* memset( this, 0, sizeof(Value) )
|
* memset( this, 0, sizeof(Value) )
|
||||||
* This optimization is used in ValueInternalMap fast allocator.
|
* This optimization is used in ValueInternalMap fast allocator.
|
||||||
*/
|
*/
|
||||||
Value::Value(ValueType type)
|
Value::Value(ValueType type) {
|
||||||
: type_(type), allocated_(false)
|
initBasic(type);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case nullValue:
|
case nullValue:
|
||||||
break;
|
break;
|
||||||
@ -267,130 +261,62 @@ Value::Value(ValueType type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(UInt value)
|
Value::Value(Int value) {
|
||||||
: type_(uintValue), allocated_(false)
|
initBasic(intValue);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
value_.int_ = value;
|
||||||
,
|
}
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
Value::Value(UInt value) {
|
||||||
,
|
initBasic(uintValue);
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.uint_ = value;
|
value_.uint_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(Int value)
|
|
||||||
: type_(intValue), allocated_(false)
|
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.int_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(JSON_HAS_INT64)
|
#if defined(JSON_HAS_INT64)
|
||||||
Value::Value(Int64 value)
|
Value::Value(Int64 value) {
|
||||||
: type_(intValue), allocated_(false)
|
initBasic(intValue);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.int_ = value;
|
value_.int_ = value;
|
||||||
}
|
}
|
||||||
|
Value::Value(UInt64 value) {
|
||||||
Value::Value(UInt64 value)
|
initBasic(uintValue);
|
||||||
: type_(uintValue), allocated_(false)
|
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.uint_ = value;
|
value_.uint_ = value;
|
||||||
}
|
}
|
||||||
#endif // defined(JSON_HAS_INT64)
|
#endif // defined(JSON_HAS_INT64)
|
||||||
|
|
||||||
Value::Value(double value)
|
Value::Value(double value) {
|
||||||
: type_(realValue), allocated_(false)
|
initBasic(realValue);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.real_ = value;
|
value_.real_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const char* value)
|
Value::Value(const char* value) {
|
||||||
: type_(stringValue), allocated_(true)
|
initBasic(stringValue, true);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.string_ = duplicateStringValue(value);
|
value_.string_ = duplicateStringValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const char* beginValue, const char* endValue)
|
Value::Value(const char* beginValue, const char* endValue) {
|
||||||
: type_(stringValue), allocated_(true)
|
initBasic(stringValue, true);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.string_ =
|
value_.string_ =
|
||||||
duplicateStringValue(beginValue, (unsigned int)(endValue - beginValue));
|
duplicateStringValue(beginValue, (unsigned int)(endValue - beginValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const std::string& value)
|
Value::Value(const std::string& value) {
|
||||||
: type_(stringValue), allocated_(true)
|
initBasic(stringValue, true);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.string_ =
|
value_.string_ =
|
||||||
duplicateStringValue(value.c_str(), (unsigned int)value.length());
|
duplicateStringValue(value.c_str(), (unsigned int)value.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const StaticString& value)
|
Value::Value(const StaticString& value) {
|
||||||
: type_(stringValue), allocated_(false)
|
initBasic(stringValue);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.string_ = const_cast<char*>(value.c_str());
|
value_.string_ = const_cast<char*>(value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
Value::Value(const CppTL::ConstString& value)
|
Value::Value(const CppTL::ConstString& value) {
|
||||||
: type_(stringValue), allocated_(true)
|
initBasic(stringValue, true);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.string_ = duplicateStringValue(value, value.length());
|
value_.string_ = duplicateStringValue(value, value.length());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Value::Value(bool value)
|
Value::Value(bool value) {
|
||||||
: type_(booleanValue), allocated_(false)
|
initBasic(booleanValue);
|
||||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
|
||||||
,
|
|
||||||
itemIsUsed_(0)
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
comments_(0), start_(0), limit_(0) {
|
|
||||||
value_.bool_ = value;
|
value_.bool_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -966,6 +892,17 @@ Value& Value::operator[](const char* key) {
|
|||||||
return resolveReference(key, false);
|
return resolveReference(key, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Value::initBasic(ValueType type, bool allocated) {
|
||||||
|
type_ = type;
|
||||||
|
allocated_ = allocated;
|
||||||
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
itemIsUsed_ = 0;
|
||||||
|
#endif
|
||||||
|
comments_ = 0;
|
||||||
|
start_ = 0;
|
||||||
|
limit_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Value& Value::resolveReference(const char* key, bool isStatic) {
|
Value& Value::resolveReference(const char* key, bool isStatic) {
|
||||||
JSON_ASSERT_MESSAGE(
|
JSON_ASSERT_MESSAGE(
|
||||||
type_ == nullValue || type_ == objectValue,
|
type_ == nullValue || type_ == objectValue,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user