mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Removed useless null checks
This commit is contained in:
		| @@ -19,10 +19,6 @@ void check(const char* input, std::string expected) { | |||||||
| } | } | ||||||
|  |  | ||||||
| TEST_CASE("TextFormatter::writeString()") { | TEST_CASE("TextFormatter::writeString()") { | ||||||
|   SECTION("Null") { |  | ||||||
|     check(0, "null"); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   SECTION("EmptyString") { |   SECTION("EmptyString") { | ||||||
|     check("", "\"\""); |     check("", "\"\""); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ | |||||||
| #include <ArduinoJson/Json/EscapeSequence.hpp> | #include <ArduinoJson/Json/EscapeSequence.hpp> | ||||||
| #include <ArduinoJson/Numbers/FloatParts.hpp> | #include <ArduinoJson/Numbers/FloatParts.hpp> | ||||||
| #include <ArduinoJson/Numbers/Integer.hpp> | #include <ArduinoJson/Numbers/Integer.hpp> | ||||||
|  | #include <ArduinoJson/Polyfills/assert.hpp> | ||||||
| #include <ArduinoJson/Polyfills/attributes.hpp> | #include <ArduinoJson/Polyfills/attributes.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| @@ -32,13 +33,10 @@ class TextFormatter { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   void writeString(const char *value) { |   void writeString(const char *value) { | ||||||
|     if (!value) { |     ARDUINOJSON_ASSERT(value != NULL); | ||||||
|       writeRaw("null"); |     writeRaw('\"'); | ||||||
|     } else { |     while (*value) writeChar(*value++); | ||||||
|       writeRaw('\"'); |     writeRaw('\"'); | ||||||
|       while (*value) writeChar(*value++); |  | ||||||
|       writeRaw('\"'); |  | ||||||
|     } |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void writeChar(char c) { |   void writeChar(char c) { | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ | |||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
| #include <ArduinoJson/MsgPack/endianess.hpp> | #include <ArduinoJson/MsgPack/endianess.hpp> | ||||||
|  | #include <ArduinoJson/Polyfills/assert.hpp> | ||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
| #include <ArduinoJson/Serialization/measure.hpp> | #include <ArduinoJson/Serialization/measure.hpp> | ||||||
| #include <ArduinoJson/Serialization/serialize.hpp> | #include <ArduinoJson/Serialization/serialize.hpp> | ||||||
| @@ -70,8 +71,7 @@ class MsgPackSerializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   void visitString(const char* value) { |   void visitString(const char* value) { | ||||||
|     if (!value) |     ARDUINOJSON_ASSERT(value != NULL); | ||||||
|       return writeByte(0xC0);  // nil |  | ||||||
|  |  | ||||||
|     size_t n = strlen(value); |     size_t n = strlen(value); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user