[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Sep 29 06:35:49 PDT 2015


 src/hb-common.cc |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit f3159ba5141c2ab0e430e64742972df140f91c43
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Sep 29 14:34:56 2015 +0100

    Micro-optimize hb_language_from_string()
    
    As measured / improved by Benson Limketkai.

diff --git a/src/hb-common.cc b/src/hb-common.cc
index 291095f..e67059d 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -293,21 +293,21 @@ retry:
 hb_language_t
 hb_language_from_string (const char *str, int len)
 {
-  char strbuf[64];
-
   if (!str || !len || !*str)
     return HB_LANGUAGE_INVALID;
 
+  hb_language_item_t *item = NULL;
   if (len >= 0)
   {
     /* NUL-terminate it. */
+    char strbuf[64];
     len = MIN (len, (int) sizeof (strbuf) - 1);
     memcpy (strbuf, str, len);
     strbuf[len] = '\0';
-    str = strbuf;
+    item = lang_find_or_insert (strbuf);
   }
-
-  hb_language_item_t *item = lang_find_or_insert (str);
+  else
+    item = lang_find_or_insert (str);
 
   return likely (item) ? item->lang : HB_LANGUAGE_INVALID;
 }


More information about the HarfBuzz mailing list