From b3c9933350e5c6b9d06a72034e681cecae52dc4b Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 16 Jul 2020 19:55:15 +1000 Subject: Add constexpr, const, noexcept and make other small improvements to lexlib. --- lexlib/PropSetSimple.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lexlib/PropSetSimple.cxx') diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx index 6e1312527..6ee57d667 100644 --- a/lexlib/PropSetSimple.cxx +++ b/lexlib/PropSetSimple.cxx @@ -21,10 +21,14 @@ namespace { typedef std::map mapss; -mapss *PropsFromPointer(void *impl) { +mapss *PropsFromPointer(void *impl) noexcept { return static_cast(impl); } +constexpr bool IsASpaceCharacter(int ch) noexcept { + return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); +} + } PropSetSimple::PropSetSimple() { @@ -35,7 +39,7 @@ PropSetSimple::PropSetSimple() { PropSetSimple::~PropSetSimple() { mapss *props = PropsFromPointer(impl); delete props; - impl = 0; + impl = nullptr; } void PropSetSimple::Set(const char *key, const char *val, size_t lenKey, size_t lenVal) { @@ -45,10 +49,6 @@ void PropSetSimple::Set(const char *key, const char *val, size_t lenKey, size_t (*props)[std::string(key, lenKey)] = std::string(val, lenVal); } -static bool IsASpaceCharacter(unsigned int ch) { - return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); -} - void PropSetSimple::Set(const char *keyVal) { while (IsASpaceCharacter(*keyVal)) keyVal++; @@ -90,7 +90,7 @@ const char *PropSetSimple::Get(const char *key) const { // for that, through a recursive function and a simple chain of pointers. struct VarChain { - VarChain(const char *var_=nullptr, const VarChain *link_= nullptr): var(var_), link(link_) {} + VarChain(const char *var_=nullptr, const VarChain *link_= nullptr) noexcept : var(var_), link(link_) {} bool contains(const char *testVar) const { return (var && (0 == strcmp(var, testVar))) -- cgit v1.2.3