mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Reduced the size of JsonArrayBase::printTo() by 18 bytes
This commit is contained in:
		| @@ -6,6 +6,7 @@ | |||||||
| #include "JsonArrayBase.h" | #include "JsonArrayBase.h" | ||||||
|  |  | ||||||
| using namespace ArduinoJson::Generator; | using namespace ArduinoJson::Generator; | ||||||
|  | using namespace ArduinoJson::Internals; | ||||||
|  |  | ||||||
| size_t JsonArrayBase::printTo(Print& p) const | size_t JsonArrayBase::printTo(Print& p) const | ||||||
| { | { | ||||||
| @@ -13,14 +14,18 @@ size_t JsonArrayBase::printTo(Print& p) const | |||||||
|  |  | ||||||
|     n += p.write('['); |     n += p.write('['); | ||||||
|  |  | ||||||
|     for (int i = 0; i < count; i++) |     // NB: the code has been optimized for a small size on a 8-bit AVR | ||||||
|     { |  | ||||||
|         if (i > 0) |     const JsonValue* current = items; | ||||||
|  |     for (int i = count; i > 0; i--) | ||||||
|  |     {        | ||||||
|  |         n += current->printTo(p); | ||||||
|  |         current++; | ||||||
|  |  | ||||||
|  |         if (i > 1) | ||||||
|         { |         { | ||||||
|             n += p.write(','); |             n += p.write(','); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         n += items[i].printTo(p); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     n += p.write(']'); |     n += p.write(']'); | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ size_t JsonHashTableBase::printTo(Print& p) const | |||||||
|  |  | ||||||
|     // NB: the code has been optimized for a small size on a 8-bit AVR |     // NB: the code has been optimized for a small size on a 8-bit AVR | ||||||
|  |  | ||||||
|     KeyValuePair* current = items; |     const KeyValuePair* current = items; | ||||||
|     for (int i = count; i > 0; i--) |     for (int i = count; i > 0; i--) | ||||||
|     {        |     {        | ||||||
|         n += current->key.printTo(p); |         n += current->key.printTo(p); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user