]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
ue2string: bring caseless cmp inline
authorJustin Viiret <justin.viiret@intel.com>
Thu, 21 Apr 2016 03:57:57 +0000 (13:57 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 18 May 2016 06:22:18 +0000 (16:22 +1000)
src/util/ue2string.cpp

index 4b16619672b0d0c7f51c1d245f26ee76f7ab9316..6fdc57ba5314cad5ef31ee5873e685ba60ecf031 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -173,7 +173,16 @@ size_t maxStringSelfOverlap(const string &a, bool nocase) {
 }
 
 u32 cmp(const char *a, const char *b, size_t len, bool nocase) {
-    return cmpForward((const u8 *)a, (const u8 *)b, len, nocase);
+    if (!nocase) {
+        return memcmp(a, b, len);
+    }
+
+    for (const auto *a_end = a + len; a < a_end; a++, b++) {
+        if (mytoupper(*a) != mytoupper(*b)) {
+            return 1;
+        }
+    }
+    return 0;
 }
 
 case_iter::case_iter(const ue2_literal &ss) : s(ss.get_string()),