]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
ucp_table: clean up make_caseless
authorJustin Viiret <justin.viiret@intel.com>
Mon, 9 May 2016 06:10:57 +0000 (16:10 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 18 May 2016 06:28:22 +0000 (16:28 +1000)
src/parser/ucp_table.cpp

index a6cb57cdd463b892a0a827b86b00fcc730a7c856..fc1330fe7f22a0a15156874d7db279a402cb3d52 100644 (file)
@@ -83,14 +83,13 @@ void make_caseless(CodePointSet *cps) {
 
     CodePointSet base = *cps;
 
-    const unicase *uc_begin = ucp_caseless_def;
-    const unicase *const uc_end = ucp_caseless_def
-                                  + ARRAY_LENGTH(ucp_caseless_def);
-    DEBUG_PRINTF("uc len %zd\n", uc_end - uc_begin);
+    auto uc_begin = begin(ucp_caseless_def);
+    auto uc_end = end(ucp_caseless_def);
+    DEBUG_PRINTF("uc len %zd\n", distance(uc_begin, uc_end));
 
-    for (auto it = base.begin(), ite = base.end(); it != ite; ++it) {
-        unichar b = lower(*it);
-        unichar e = upper(*it) + 1;
+    for (const auto &elem : base) {
+        unichar b = lower(elem);
+        unichar e = upper(elem) + 1;
 
         for (; b < e; b++) {
             DEBUG_PRINTF("decasing %x\n", b);
@@ -101,7 +100,7 @@ void make_caseless(CodePointSet *cps) {
                 DEBUG_PRINTF("EOL\n");
                 return;
             }
-            while (uc_begin->base == b) {
+            while (uc_begin != uc_end && uc_begin->base == b) {
                 DEBUG_PRINTF("at {%x,%x}\n", uc_begin->base, uc_begin->caseless);
                 cps->set(uc_begin->caseless);
                 ++uc_begin;