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()") { | ||||
|   SECTION("Null") { | ||||
|     check(0, "null"); | ||||
|   } | ||||
|  | ||||
|   SECTION("EmptyString") { | ||||
|     check("", "\"\""); | ||||
|   } | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
| #include <ArduinoJson/Json/EscapeSequence.hpp> | ||||
| #include <ArduinoJson/Numbers/FloatParts.hpp> | ||||
| #include <ArduinoJson/Numbers/Integer.hpp> | ||||
| #include <ArduinoJson/Polyfills/assert.hpp> | ||||
| #include <ArduinoJson/Polyfills/attributes.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| @@ -32,14 +33,11 @@ class TextFormatter { | ||||
|   } | ||||
|  | ||||
|   void writeString(const char *value) { | ||||
|     if (!value) { | ||||
|       writeRaw("null"); | ||||
|     } else { | ||||
|     ARDUINOJSON_ASSERT(value != NULL); | ||||
|     writeRaw('\"'); | ||||
|     while (*value) writeChar(*value++); | ||||
|     writeRaw('\"'); | ||||
|   } | ||||
|   } | ||||
|  | ||||
|   void writeChar(char c) { | ||||
|     char specialChar = EscapeSequence::escapeChar(c); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <ArduinoJson/MsgPack/endianess.hpp> | ||||
| #include <ArduinoJson/Polyfills/assert.hpp> | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #include <ArduinoJson/Serialization/measure.hpp> | ||||
| #include <ArduinoJson/Serialization/serialize.hpp> | ||||
| @@ -70,8 +71,7 @@ class MsgPackSerializer { | ||||
|   } | ||||
|  | ||||
|   void visitString(const char* value) { | ||||
|     if (!value) | ||||
|       return writeByte(0xC0);  // nil | ||||
|     ARDUINOJSON_ASSERT(value != NULL); | ||||
|  | ||||
|     size_t n = strlen(value); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user