From 25146bfa93d139f40fd3e339f76da7a6b9e6e8bb Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 12 Feb 2024 01:00:54 +0200 Subject: [PATCH] Replace custom class with string_view --- lib/json/JsonParser.h | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/lib/json/JsonParser.h b/lib/json/JsonParser.h index 7d975927d..5ab544e41 100644 --- a/lib/json/JsonParser.h +++ b/lib/json/JsonParser.h @@ -13,37 +13,11 @@ VCMI_LIB_NAMESPACE_BEGIN -//Tiny string class that uses const char* as data for speed, members are private -//for ease of debugging and some compatibility with std::string -class constString -{ - const char *data; - const size_t datasize; - -public: - constString(const char * inputString, size_t stringSize): - data(inputString), - datasize(stringSize) - { - } - - inline size_t size() const - { - return datasize; - }; - - inline const char& operator[] (size_t position) - { - assert (position < datasize); - return data[position]; - } -}; - //Internal class for string -> JsonNode conversion class JsonParser { std::string errors; // Contains description of all encountered errors - constString input; // Input data + std::string_view input; // Input data ui32 lineCount; // Currently parsed line, starting from 1 size_t lineStart; // Position of current line start size_t pos; // Current position of parser