forked from bblanchon/ArduinoJson
Reduced stack usage when compiler aggressively inlines deserializeJson()
This saves 64 bytes on the recursive part.
This commit is contained in:
@ -439,18 +439,17 @@ class JsonDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeserializationError parseNumericValue(VariantData &result) {
|
DeserializationError parseNumericValue(VariantData &result) {
|
||||||
char buffer[64];
|
|
||||||
uint8_t n = 0;
|
uint8_t n = 0;
|
||||||
|
|
||||||
char c = current();
|
char c = current();
|
||||||
while (canBeInNonQuotedString(c) && n < 63) {
|
while (canBeInNonQuotedString(c) && n < 63) {
|
||||||
move();
|
move();
|
||||||
buffer[n++] = c;
|
_buffer[n++] = c;
|
||||||
c = current();
|
c = current();
|
||||||
}
|
}
|
||||||
buffer[n] = 0;
|
_buffer[n] = 0;
|
||||||
|
|
||||||
c = buffer[0];
|
c = _buffer[0];
|
||||||
if (c == 't') { // true
|
if (c == 't') { // true
|
||||||
result.setBoolean(true);
|
result.setBoolean(true);
|
||||||
return n == 4 ? DeserializationError::Ok
|
return n == 4 ? DeserializationError::Ok
|
||||||
@ -467,7 +466,7 @@ class JsonDeserializer {
|
|||||||
: DeserializationError::IncompleteInput;
|
: DeserializationError::IncompleteInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParsedNumber<Float, UInt> num = parseNumber<Float, UInt>(buffer);
|
ParsedNumber<Float, UInt> num = parseNumber<Float, UInt>(_buffer);
|
||||||
|
|
||||||
switch (num.type()) {
|
switch (num.type()) {
|
||||||
case VALUE_IS_NEGATIVE_INTEGER:
|
case VALUE_IS_NEGATIVE_INTEGER:
|
||||||
@ -597,6 +596,9 @@ class JsonDeserializer {
|
|||||||
TStringStorage _stringStorage;
|
TStringStorage _stringStorage;
|
||||||
Latch<TReader> _latch;
|
Latch<TReader> _latch;
|
||||||
MemoryPool *_pool;
|
MemoryPool *_pool;
|
||||||
|
char _buffer[64]; // using a member instead of a local variable because it
|
||||||
|
// ended in the recursive path after compiler inlined the
|
||||||
|
// code
|
||||||
};
|
};
|
||||||
|
|
||||||
// deserializeJson(JsonDocument&, const std::string&, ...)
|
// deserializeJson(JsonDocument&, const std::string&, ...)
|
||||||
|
Reference in New Issue
Block a user