From dbbbcd1cbe9986aedfaf6362fdaef61999ab9a75 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 26 Dec 2019 00:55:14 +0000 Subject: [PATCH] Do not compare raw string pointers in water::Identifier Fixes #986 --- source/modules/water/text/Identifier.cpp | 2 -- source/modules/water/text/Identifier.h | 13 ++----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/source/modules/water/text/Identifier.cpp b/source/modules/water/text/Identifier.cpp index 8ebd43460..e542d6eeb 100644 --- a/source/modules/water/text/Identifier.cpp +++ b/source/modules/water/text/Identifier.cpp @@ -69,8 +69,6 @@ Identifier::Identifier (String::CharPointerType start, String::CharPointerType e wassert (start < end); } -Identifier Identifier::null; - bool Identifier::isValidIdentifier (const String& possibleIdentifier) noexcept { return possibleIdentifier.isNotEmpty() diff --git a/source/modules/water/text/Identifier.h b/source/modules/water/text/Identifier.h index 92e31b281..a044b3a3a 100644 --- a/source/modules/water/text/Identifier.h +++ b/source/modules/water/text/Identifier.h @@ -82,10 +82,10 @@ public: ~Identifier() noexcept; /** Compares two identifiers. This is a very fast operation. */ - inline bool operator== (const Identifier& other) const noexcept { return name.getCharPointer() == other.name.getCharPointer(); } + inline bool operator== (const Identifier& other) const noexcept { return name == other.name; } /** Compares two identifiers. This is a very fast operation. */ - inline bool operator!= (const Identifier& other) const noexcept { return name.getCharPointer() != other.name.getCharPointer(); } + inline bool operator!= (const Identifier& other) const noexcept { return name != other.name; } /** Compares the identifier with a string. */ inline bool operator== (StringRef other) const noexcept { return name == other; } @@ -108,12 +108,6 @@ public: /** Returns this identifier as a string. */ const String& toString() const noexcept { return name; } - /** Returns this identifier's raw string pointer. */ - operator String::CharPointerType() const noexcept { return name.getCharPointer(); } - - /** Returns this identifier's raw string pointer. */ - String::CharPointerType getCharPointer() const noexcept { return name.getCharPointer(); } - /** Returns this identifier as a StringRef. */ operator StringRef() const noexcept { return name; } @@ -123,9 +117,6 @@ public: /** Returns true if this Identifier is null */ bool isNull() const noexcept { return name.isEmpty(); } - /** A null identifier. */ - static Identifier null; - /** Checks a given string for characters that might not be valid in an Identifier. Since Identifiers are used as a script variables and XML attributes, they should only contain alphanumeric characters, underscores, or the '-' and ':' characters.