diff --git a/src/ucioption.cpp b/src/ucioption.cpp
index 1dfc474a..9e718c02 100644
--- a/src/ucioption.cpp
+++ b/src/ucioption.cpp
@@ -17,6 +17,7 @@
along with this program. If not, see .
*/
+#include
#include
#include
#include
@@ -33,20 +34,10 @@ OptionsMap Options; // Global object
// Our case insensitive less() function as required by UCI protocol
+static bool ci_less(char c1, char c2) { return tolower(c1) < tolower(c2); }
+
bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const {
-
- int c1, c2;
- size_t i = 0;
-
- while (i < s1.size() && i < s2.size())
- {
- c1 = tolower(s1[i]);
- c2 = tolower(s2[i++]);
-
- if (c1 != c2)
- return c1 < c2;
- }
- return s1.size() < s2.size();
+ return std::lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(), ci_less);
}
diff --git a/src/ucioption.h b/src/ucioption.h
index b6ad959c..c764ac8b 100644
--- a/src/ucioption.h
+++ b/src/ucioption.h
@@ -36,7 +36,7 @@ public:
template T value() const;
private:
- friend class OptionsMap;
+ friend struct OptionsMap;
std::string defaultValue, currentValue, type;
int minValue, maxValue;
@@ -44,15 +44,14 @@ private:
};
-/// Custom comparator because UCI options should not be case sensitive
+/// Custom comparator because UCI options should be case insensitive
struct CaseInsensitiveLess {
bool operator() (const std::string&, const std::string&) const;
};
/// Our options container is actually a map with a customized c'tor
-class OptionsMap : public std::map {
-public:
+struct OptionsMap : std::map {
OptionsMap();
std::string print_all() const;
};