]> git.sesse.net Git - stockfish/blobdiff - src/ucioption.cpp
Use ADL to skip std:: qualifier
[stockfish] / src / ucioption.cpp
index 1dfc474a9c0a3098ce82e0aa181dfb1bfa89195a..7b8799c48dcec9285c5d5bc10276e07619880515 100644 (file)
@@ -17,8 +17,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <cctype>
-#include <iostream>
+#include <algorithm>
 #include <sstream>
 
 #include "misc.h"
 #include "ucioption.h"
 
 using std::string;
-using std::cout;
-using std::endl;
 
 OptionsMap Options; // Global object
 
 
 // Our case insensitive less() function as required by UCI protocol
-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++]);
+static bool ci_less(char c1, char c2) { return tolower(c1) < tolower(c2); }
 
-      if (c1 != c2)
-          return c1 < c2;
-  }
-  return s1.size() < s2.size();
+bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const {
+  return lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(), ci_less);
 }