projects
/
jansson.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d77c2e3
)
remove some unnecessary checks
author
Sean Middleditch
<sean@middleditch.us>
Tue, 12 Jan 2010 12:30:02 +0000
(
04:30
-0800)
committer
Sean Middleditch
<sean@middleditch.us>
Tue, 12 Jan 2010 12:30:02 +0000
(
04:30
-0800)
janssonxx.h
patch
|
blob
|
history
diff --git
a/janssonxx.h
b/janssonxx.h
index
6f83ef1
..
cfc1058
100644
(file)
--- a/
janssonxx.h
+++ b/
janssonxx.h
@@
-90,18
+90,13
@@
public:
unsigned int size() const {
if (is_object())
return json_object_size(_value);
unsigned int size() const {
if (is_object())
return json_object_size(_value);
- else if (is_array())
- return json_array_size(_value);
else
else
- return
0
;
+ return
json_array_size(_value)
;
}
// get value at array index (const version)
const Value at(unsigned int index) const {
}
// get value at array index (const version)
const Value at(unsigned int index) const {
- if (is_array())
- return Value(json_array_get(_value, index));
- else
- return Value();
+ return Value(json_array_get(_value, index));
}
const Value operator[](signed int index) const { return at(index); }
}
const Value operator[](signed int index) const { return at(index); }
@@
-113,10
+108,7
@@
public:
// get value at array index (non-const version)
Value at(unsigned int index) {
// get value at array index (non-const version)
Value at(unsigned int index) {
- if (is_array())
- return Value(json_array_get(_value, index));
- else
- return Value();
+ return Value(json_array_get(_value, index));
}
Value operator[](signed int index) { return at(index); }
}
Value operator[](signed int index) { return at(index); }
@@
-128,10
+120,7
@@
public:
// get object property
const Value get(const char* key) const {
// get object property
const Value get(const char* key) const {
- if (is_object())
- return Value(json_object_get(_value, key));
- else
- return Value();
+ return Value(json_object_get(_value, key));
}
const Value get(const std::string& key) const { return get(key.c_str()); }
}
const Value get(const std::string& key) const { return get(key.c_str()); }
@@
-142,7
+131,7
@@
public:
void clear() {
if (is_object())
json_object_clear(_value);
void clear() {
if (is_object())
json_object_clear(_value);
- else
if (is_array())
+ else
json_array_clear(_value);
}
json_array_clear(_value);
}
@@
-205,8
+194,7
@@
public:
// increment iterator
void next() {
// increment iterator
void next() {
- if (_iter != 0)
- _iter = json_object_iter_next(_object.as_json_t(), _iter);
+ _iter = json_object_iter_next(_object.as_json_t(), _iter);
}
Iterator& operator++() { next(); return *this; }
}
Iterator& operator++() { next(); return *this; }
@@
-217,20
+205,14
@@
public:
// get key
const char* ckey() const {
// get key
const char* ckey() const {
- if (_iter != 0)
- return json_object_iter_key(_iter);
- else
- return "";
+ return json_object_iter_key(_iter);
}
std::string key() const { return ckey(); }
// get value
const Value value() const {
}
std::string key() const { return ckey(); }
// get value
const Value value() const {
- if (_iter != 0)
- return Value(json_object_iter_value(_iter));
- else
- return Value();
+ return Value(json_object_iter_value(_iter));
}
// dereference value
}
// dereference value