@@ -21,10 +21,11 @@ class JsonArray {
21
21
public:
22
22
typedef JsonArrayIterator iterator;
23
23
24
- JsonArray () : _buffer(0 ), _data(0 ) {}
25
- explicit JsonArray (Internals::JsonBuffer* buf, Internals::JsonArrayData* arr)
24
+ FORCE_INLINE JsonArray () : _buffer(0 ), _data(0 ) {}
25
+ FORCE_INLINE JsonArray (Internals::JsonBuffer* buf,
26
+ Internals::JsonArrayData* arr)
26
27
: _buffer(buf), _data(arr) {}
27
- explicit JsonArray (Internals::JsonBuffer* buf)
28
+ FORCE_INLINE explicit JsonArray (Internals::JsonBuffer* buf)
28
29
: _buffer(buf), _data(new (buf) Internals::JsonArrayData()) {}
29
30
30
31
// Adds the specified value at the end of the array.
@@ -33,29 +34,29 @@ class JsonArray {
33
34
// TValue = bool, long, int, short, float, double, serialized, JsonVariant,
34
35
// std::string, String, JsonArrayData, JsonObject
35
36
template <typename T>
36
- bool add (const T& value) {
37
+ FORCE_INLINE bool add (const T& value) {
37
38
return add_impl<const T&>(value);
38
39
}
39
40
//
40
41
// bool add(TValue);
41
42
// TValue = char*, const char*, const FlashStringHelper*
42
43
template <typename T>
43
- bool add (T* value) {
44
+ FORCE_INLINE bool add (T* value) {
44
45
return add_impl<T*>(value);
45
46
}
46
47
47
- iterator begin () const {
48
+ FORCE_INLINE iterator begin () const {
48
49
if (!_data) return iterator ();
49
50
return iterator (_buffer, _data->begin ());
50
51
}
51
52
52
- iterator end () const {
53
+ FORCE_INLINE iterator end () const {
53
54
return iterator ();
54
55
}
55
56
56
57
// Imports a 1D array
57
58
template <typename T, size_t N>
58
- bool copyFrom (T (&array)[N]) {
59
+ FORCE_INLINE bool copyFrom (T (&array)[N]) {
59
60
return copyFrom (array, N);
60
61
}
61
62
@@ -84,7 +85,7 @@ class JsonArray {
84
85
85
86
// Exports a 1D array
86
87
template <typename T, size_t N>
87
- size_t copyTo (T (&array)[N]) const {
88
+ FORCE_INLINE size_t copyTo (T (&array)[N]) const {
88
89
return copyTo (array, N);
89
90
}
90
91
@@ -106,39 +107,41 @@ class JsonArray {
106
107
}
107
108
}
108
109
109
- JsonArray createNestedArray ();
110
- JsonObject createNestedObject ();
110
+ FORCE_INLINE JsonArray createNestedArray ();
111
+ FORCE_INLINE JsonObject createNestedObject ();
111
112
112
- Internals::JsonArraySubscript operator [](size_t index);
113
+ FORCE_INLINE Internals::JsonArraySubscript operator [](size_t index);
113
114
114
- const Internals::JsonArraySubscript operator [](size_t index) const ;
115
+ FORCE_INLINE const Internals::JsonArraySubscript operator [](
116
+ size_t index) const ;
115
117
116
- bool operator ==(const JsonArray& rhs) const {
118
+ FORCE_INLINE bool operator ==(const JsonArray& rhs) const {
117
119
return _data == rhs._data ;
118
120
}
119
121
120
122
// Gets the value at the specified index.
121
123
template <typename T>
122
- typename Internals::JsonVariantAs<T>::type get (size_t index) const {
124
+ FORCE_INLINE typename Internals::JsonVariantAs<T>::type get (
125
+ size_t index) const {
123
126
iterator it = begin () += index;
124
127
return it != end () ? it->as <T>() : T ();
125
128
}
126
129
127
130
// Check the type of the value at specified index.
128
131
template <typename T>
129
- bool is (size_t index) const {
132
+ FORCE_INLINE bool is (size_t index) const {
130
133
iterator it = begin () += index;
131
134
return it != end () ? it->is <T>() : false ;
132
135
}
133
136
134
137
// Removes element at specified position.
135
- void remove (iterator it) {
138
+ FORCE_INLINE void remove (iterator it) {
136
139
if (!_data) return ;
137
140
_data->remove (it.internal ());
138
141
}
139
142
140
143
// Removes element at specified index.
141
- void remove (size_t index) {
144
+ FORCE_INLINE void remove (size_t index) {
142
145
remove (begin () += index);
143
146
}
144
147
@@ -148,30 +151,30 @@ class JsonArray {
148
151
// TValue = bool, long, int, short, float, double, serialized, JsonVariant,
149
152
// std::string, String, JsonArrayData, JsonObject
150
153
template <typename T>
151
- bool set (size_t index, const T& value) {
154
+ FORCE_INLINE bool set (size_t index, const T& value) {
152
155
if (!_data) return false ;
153
156
return set_impl<const T&>(index, value);
154
157
}
155
158
//
156
159
// bool add(size_t index, TValue);
157
160
// TValue = char*, const char*, const FlashStringHelper*
158
161
template <typename T>
159
- bool set (size_t index, T* value) {
162
+ FORCE_INLINE bool set (size_t index, T* value) {
160
163
if (!_data) return false ;
161
164
return set_impl<T*>(index, value);
162
165
}
163
166
164
- size_t size () const {
167
+ FORCE_INLINE size_t size () const {
165
168
if (!_data) return 0 ;
166
169
return _data->size ();
167
170
}
168
171
169
- bool isNull () const {
172
+ FORCE_INLINE bool isNull () const {
170
173
return _data == 0 ;
171
174
}
172
175
173
176
template <typename Visitor>
174
- void visit (Visitor& visitor) const {
177
+ FORCE_INLINE void visit (Visitor& visitor) const {
175
178
if (_data)
176
179
visitor.acceptArray (*_data);
177
180
else
@@ -180,14 +183,14 @@ class JsonArray {
180
183
181
184
private:
182
185
template <typename TValueRef>
183
- bool set_impl (size_t index, TValueRef value) {
186
+ FORCE_INLINE bool set_impl (size_t index, TValueRef value) {
184
187
iterator it = begin () += index;
185
188
if (it == end ()) return false ;
186
189
return it->set (value);
187
190
}
188
191
189
192
template <typename TValueRef>
190
- bool add_impl (TValueRef value) {
193
+ FORCE_INLINE bool add_impl (TValueRef value) {
191
194
if (!_data) return false ;
192
195
iterator it = iterator (_buffer, _data->add (_buffer));
193
196
if (it == end ()) return false ;
0 commit comments