Revert "Use constexpr to replace passthru_ bools"
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 3 Jul 2019 02:44:18 +0000 (19:44 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 3 Jul 2019 02:44:18 +0000 (19:44 -0700)
This reverts commit c4aa10ebc8dc28b1f9c90af2ca2092a7535f8395.

Broke several compilers... Sigh.  The version without constexpr
didn't fully optimize out the unreachable code on clang.
So, revert it is...

src/hb-algs.hh
src/hb-set.hh

index 5d8c8dd..7886894 100644 (file)
@@ -915,24 +915,32 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o
 
 struct hb_bitwise_and
 { HB_PARTIALIZE(2);
+  static constexpr bool passthru_left = false;
+  static constexpr bool passthru_right = false;
   template <typename T> constexpr auto
   operator () (const T &a, const T &b) const HB_AUTO_RETURN (a & b)
 }
 HB_FUNCOBJ (hb_bitwise_and);
 struct hb_bitwise_or
 { HB_PARTIALIZE(2);
+  static constexpr bool passthru_left = true;
+  static constexpr bool passthru_right = true;
   template <typename T> constexpr auto
   operator () (const T &a, const T &b) const HB_AUTO_RETURN (a | b)
 }
 HB_FUNCOBJ (hb_bitwise_or);
 struct hb_bitwise_xor
 { HB_PARTIALIZE(2);
+  static constexpr bool passthru_left = true;
+  static constexpr bool passthru_right = true;
   template <typename T> constexpr auto
   operator () (const T &a, const T &b) const HB_AUTO_RETURN (a ^ b)
 }
 HB_FUNCOBJ (hb_bitwise_xor);
 struct hb_bitwise_sub
 { HB_PARTIALIZE(2);
+  static constexpr bool passthru_left = true;
+  static constexpr bool passthru_right = false;
   template <typename T> constexpr auto
   operator () (const T &a, const T &b) const HB_AUTO_RETURN (a & ~b)
 }
index 11034af..ad449d0 100644 (file)
@@ -448,8 +448,6 @@ struct hb_set_t
 
     dirty ();
 
-    constexpr bool passthru_left  = op (0, 0) || op (1, 0);
-    constexpr bool passthru_right = op (0, 0) || op (0, 1);
     unsigned int na = pages.length;
     unsigned int nb = other->pages.length;
     unsigned int next_page = na;
@@ -466,20 +464,20 @@ struct hb_set_t
       }
       else if (page_map[a].major < other->page_map[b].major)
       {
-        if (passthru_left)
+        if (Op::passthru_left)
          count++;
         a++;
       }
       else
       {
-        if (passthru_right)
+        if (Op::passthru_right)
          count++;
         b++;
       }
     }
-    if (passthru_left)
+    if (Op::passthru_left)
       count += na - a;
-    if (passthru_right)
+    if (Op::passthru_right)
       count += nb - b;
 
     if (count > pages.length)
@@ -503,7 +501,7 @@ struct hb_set_t
       else if (page_map[a - 1].major > other->page_map[b - 1].major)
       {
        a--;
-       if (passthru_left)
+       if (Op::passthru_left)
        {
          count--;
          page_map[count] = page_map[a];
@@ -512,7 +510,7 @@ struct hb_set_t
       else
       {
        b--;
-       if (passthru_right)
+       if (Op::passthru_right)
        {
          count--;
          page_map[count].major = other->page_map[b].major;
@@ -521,14 +519,14 @@ struct hb_set_t
        }
       }
     }
-    if (passthru_left)
+    if (Op::passthru_left)
       while (a)
       {
        a--;
        count--;
        page_map[count] = page_map [a];
       }
-    if (passthru_right)
+    if (Op::passthru_right)
       while (b)
       {
        b--;