diff options
author | Neil <nyamatongwe@gmail.com> | 2019-03-23 08:49:33 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2019-03-23 08:49:33 +1100 |
commit | aab14ccb791a798262642dbfcaad6fd3ee381873 (patch) | |
tree | b473661ee0c9dd837d25f1146feacdae0a469215 | |
parent | 8519ba420c4e51973d792309fdd0c888914e1d5b (diff) | |
download | scintilla-mirror-aab14ccb791a798262642dbfcaad6fd3ee381873.tar.gz |
Add Contains(char) to avoid casts in client code. Remove cast in AddString.
-rw-r--r-- | lexlib/CharacterSet.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lexlib/CharacterSet.h b/lexlib/CharacterSet.h index 7c2a1fe48..358f6bed3 100644 --- a/lexlib/CharacterSet.h +++ b/lexlib/CharacterSet.h @@ -82,10 +82,9 @@ public: } void AddString(const char *setToAdd) { for (const char *cp=setToAdd; *cp; cp++) { - int val = static_cast<unsigned char>(*cp); - assert(val >= 0); - assert(val < size); - bset[val] = true; + const unsigned char uch = *cp; + assert(uch < size); + bset[uch] = true; } } bool Contains(int val) const { @@ -93,6 +92,11 @@ public: if (val < 0) return false; return (val < size) ? bset[val] : valueAfter; } + bool Contains(char ch) const { + // Overload char as char may be signed + const unsigned char uch = ch; + return Contains(uch); + } }; // Functions for classifying characters |