[HarfBuzz] harfbuzz: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Oct 23 18:29:34 UTC 2017


 src/hb-set-private.hh |   27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

New commits:
commit 30a591e3cef67818ef1ffec92c6a022b5a5f5e77
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Oct 23 14:28:35 2017 -0400

    [set] Rewrite another way :P

diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 58864287..0454a189 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -274,11 +274,11 @@ struct hb_set_t
   {
     if (unlikely (in_error)) return;
 
-    int na = pages.len;
-    int nb = other->pages.len;
+    unsigned int na = pages.len;
+    unsigned int nb = other->pages.len;
 
     unsigned int count = 0;
-    int a = 0, b = 0;
+    unsigned int a = 0, b = 0;
     for (; a < na && b < nb; )
     {
       if (page_map[a].major == other->page_map[b].major)
@@ -309,34 +309,35 @@ struct hb_set_t
       return;
 
     /* Process in-place backward. */
-    a = na - 1, b = nb - 1;
-    for (; a >= 0 && b >= 0; )
+    a = na;
+    b = nb;
+    for (; a && b; )
     {
       if (page_map[a].major == other->page_map[b].major)
       {
-        Op::process (page_at (--count).v, page_at (a).v, other->page_at (b).v);
 	a--;
 	b--;
+        Op::process (page_at (--count).v, page_at (a).v, other->page_at (b).v);
       }
       else if (page_map[a].major > other->page_map[b].major)
       {
+        a--;
         if (Op::passthru_left)
 	  page_at (--count).v = page_at (a).v;
-        a--;
       }
       else
       {
+        b--;
         if (Op::passthru_right)
 	  page_at (--count).v = other->page_at (b).v;
-        b--;
       }
     }
     if (Op::passthru_left)
-      while (a >= 0)
-	page_at (--count).v = page_at (a--).v;
+      while (a)
+	page_at (--count).v = page_at (--a).v;
     if (Op::passthru_right)
-      while (b >= 0)
-	page_at (--count).v = other->page_at (b--).v;
+      while (b)
+	page_at (--count).v = other->page_at (--b).v;
     assert (!count);
   }
 
commit 8170801d78a5bf9480d8c06ade849b30bc4e2956
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Oct 23 14:26:48 2017 -0400

    [set] Fix crash
    
    Ouch!  That's what happens when one plays with increment/decrement operators!
    
    Fixes https://github.com/behdad/harfbuzz/issues/578

diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index de34d172..58864287 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -331,10 +331,12 @@ struct hb_set_t
         b--;
       }
     }
-    while (a >= 0)
-      page_at (--count).v = page_at (--a).v;
-    while (b >= 0)
-      page_at (--count).v = other->page_at (--b).v;
+    if (Op::passthru_left)
+      while (a >= 0)
+	page_at (--count).v = page_at (a--).v;
+    if (Op::passthru_right)
+      while (b >= 0)
+	page_at (--count).v = other->page_at (b--).v;
     assert (!count);
   }
 


More information about the HarfBuzz mailing list