Browse Source

Do not compare raw string pointers in water::Identifier

Fixes #986
tags/v2.1-rc1
falkTX 4 years ago
parent
commit
dbbbcd1cbe
2 changed files with 2 additions and 13 deletions
  1. +0
    -2
      source/modules/water/text/Identifier.cpp
  2. +2
    -11
      source/modules/water/text/Identifier.h

+ 0
- 2
source/modules/water/text/Identifier.cpp View File

@@ -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()


+ 2
- 11
source/modules/water/text/Identifier.h View File

@@ -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.


Loading…
Cancel
Save