diff --git a/src/ArduinoJson/Memory/MemoryPool.hpp b/src/ArduinoJson/Memory/MemoryPool.hpp index c8262186..7d3cd0c6 100644 --- a/src/ArduinoJson/Memory/MemoryPool.hpp +++ b/src/ArduinoJson/Memory/MemoryPool.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include // memmove @@ -64,7 +65,7 @@ class MemoryPool { return 0; #if ARDUINOJSON_ENABLE_STRING_DEDUPLICATION - const char* existingCopy = findString(str.begin()); + const char* existingCopy = findString(str); if (existingCopy) return existingCopy; #endif @@ -86,7 +87,7 @@ class MemoryPool { const char* saveStringFromFreeZone(size_t len) { #if ARDUINOJSON_ENABLE_STRING_DEDUPLICATION - const char* dup = findString(_left); + const char* dup = findString(adaptString(_left)); if (dup) return dup; #endif @@ -163,16 +164,11 @@ class MemoryPool { } #if ARDUINOJSON_ENABLE_STRING_DEDUPLICATION - template - const char* findString(TIterator str) { + template + const char* findString(const TAdaptedString& str) { for (char* next = _begin; next < _left; ++next) { - char* begin = next; - - // try to match - for (TIterator it = str; *it == *next; ++it) { - if (*next++ == 0) - return begin; - } + if (str.equals(next)) + return next; // jump to next terminator while (*next) ++next; diff --git a/src/ArduinoJson/Strings/ArduinoStringAdapter.hpp b/src/ArduinoJson/Strings/ArduinoStringAdapter.hpp index 24646ccd..3797d686 100644 --- a/src/ArduinoJson/Strings/ArduinoStringAdapter.hpp +++ b/src/ArduinoJson/Strings/ArduinoStringAdapter.hpp @@ -39,10 +39,6 @@ class ArduinoStringAdapter { return _str->length(); } - const char* begin() const { - return _str->c_str(); - } - typedef storage_policies::store_by_copy storage_policy; private: diff --git a/src/ArduinoJson/Strings/ConstRamStringAdapter.hpp b/src/ArduinoJson/Strings/ConstRamStringAdapter.hpp index ec7d53a6..92298acf 100644 --- a/src/ArduinoJson/Strings/ConstRamStringAdapter.hpp +++ b/src/ArduinoJson/Strings/ConstRamStringAdapter.hpp @@ -39,10 +39,6 @@ class ConstRamStringAdapter { return _str; } - const char* begin() const { - return _str; - } - typedef storage_policies::store_by_address storage_policy; protected: diff --git a/src/ArduinoJson/Strings/FlashStringAdapter.hpp b/src/ArduinoJson/Strings/FlashStringAdapter.hpp index 292e348b..918a535c 100644 --- a/src/ArduinoJson/Strings/FlashStringAdapter.hpp +++ b/src/ArduinoJson/Strings/FlashStringAdapter.hpp @@ -5,7 +5,6 @@ #pragma once #include -#include #include #include @@ -43,10 +42,6 @@ class FlashStringAdapter { return strlen_P(reinterpret_cast(_str)); } - FlashStringIterator begin() const { - return FlashStringIterator(_str); - } - typedef storage_policies::store_by_copy storage_policy; private: diff --git a/src/ArduinoJson/Strings/FlashStringIterator.hpp b/src/ArduinoJson/Strings/FlashStringIterator.hpp deleted file mode 100644 index 9a97f324..00000000 --- a/src/ArduinoJson/Strings/FlashStringIterator.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// ArduinoJson - https://arduinojson.org -// Copyright Benoit Blanchon 2014-2021 -// MIT License - -#pragma once - -namespace ARDUINOJSON_NAMESPACE { - -class FlashStringIterator { - public: - explicit FlashStringIterator(const __FlashStringHelper* ptr) - : _ptr(reinterpret_cast(ptr)) {} - - explicit FlashStringIterator(const char* ptr) : _ptr(ptr) {} - - FlashStringIterator operator+(ptrdiff_t d) const { - return FlashStringIterator(_ptr + d); - } - - ptrdiff_t operator-(FlashStringIterator other) const { - return _ptr - other._ptr; - } - - FlashStringIterator operator++(int) { - return FlashStringIterator(_ptr++); - } - - FlashStringIterator operator++() { - return FlashStringIterator(++_ptr); - } - - bool operator!=(FlashStringIterator other) const { - return _ptr != other._ptr; - } - - char operator*() const { - return char(pgm_read_byte(_ptr)); - } - - private: - const char* _ptr; -}; - -} // namespace ARDUINOJSON_NAMESPACE diff --git a/src/ArduinoJson/Strings/SizedFlashStringAdapter.hpp b/src/ArduinoJson/Strings/SizedFlashStringAdapter.hpp index b9cc0bff..1055f666 100644 --- a/src/ArduinoJson/Strings/SizedFlashStringAdapter.hpp +++ b/src/ArduinoJson/Strings/SizedFlashStringAdapter.hpp @@ -5,7 +5,6 @@ #pragma once #include -#include #include #include @@ -42,10 +41,6 @@ class SizedFlashStringAdapter { return _size; } - FlashStringIterator begin() const { - return FlashStringIterator(_str); - } - typedef storage_policies::store_by_copy storage_policy; private: diff --git a/src/ArduinoJson/Strings/SizedRamStringAdapter.hpp b/src/ArduinoJson/Strings/SizedRamStringAdapter.hpp index fe23408f..62460a19 100644 --- a/src/ArduinoJson/Strings/SizedRamStringAdapter.hpp +++ b/src/ArduinoJson/Strings/SizedRamStringAdapter.hpp @@ -36,10 +36,6 @@ class SizedRamStringAdapter { return _size; } - const char* begin() const { - return _str; - } - typedef storage_policies::store_by_copy storage_policy; private: diff --git a/src/ArduinoJson/Strings/StdStringAdapter.hpp b/src/ArduinoJson/Strings/StdStringAdapter.hpp index ebf4c396..3979070e 100644 --- a/src/ArduinoJson/Strings/StdStringAdapter.hpp +++ b/src/ArduinoJson/Strings/StdStringAdapter.hpp @@ -41,10 +41,6 @@ class StdStringAdapter { return _str->size(); } - const char* begin() const { - return _str->c_str(); - } - typedef storage_policies::store_by_copy storage_policy; private: