]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove ObjC blocks (Bug#23753)
authorAlan Third <alan@idiocy.org>
Sun, 10 Dec 2017 10:16:25 +0000 (10:16 +0000)
committerAlan Third <alan@idiocy.org>
Tue, 12 Dec 2017 20:36:40 +0000 (20:36 +0000)
* src/macfont.m (macfont_get_glyph_for_character):
(mac_font_get_glyphs_for_variants): Inline Objective-C blocks.

(cherry picked from commit 4590f1d768adbb2120a2b02c614f7ed3b21a4a3e)

src/macfont.m

index 97879506ba4cae74e5d3d53feab75ef67adbc9e3..6985364b34e7b6b69e798b389fa93eb45fa8ba25 100644 (file)
@@ -1443,6 +1443,7 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c)
           int nrows;
           dispatch_queue_t queue;
           dispatch_group_t group = NULL;
+          int nkeys;
 
           if (row != 0)
             {
@@ -1479,23 +1480,16 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c)
                   return glyph;
                 }
 
-              queue =
-                dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-              group = dispatch_group_create ();
-              dispatch_group_async (group, queue, ^{
-                  int nkeys;
-                  uintptr_t key;
-                  nkeys = nkeys_or_perm;
-                  for (key = row * (256 / NGLYPHS_IN_VALUE); ; key++)
-                    if (CFDictionaryContainsKey (dictionary,
-                                                 (const void *) key))
-                      {
-                        CFDictionaryRemoveValue (dictionary,
-                                                 (const void *) key);
-                        if (--nkeys == 0)
-                          break;
-                      }
-                });
+              nkeys = nkeys_or_perm;
+              for (key = row * (256 / NGLYPHS_IN_VALUE); ; key++)
+                if (CFDictionaryContainsKey (dictionary,
+                                             (const void *) key))
+                  {
+                    CFDictionaryRemoveValue (dictionary,
+                                             (const void *) key);
+                    if (--nkeys == 0)
+                      break;
+                  }
             }
 
           len = 0;
@@ -1535,12 +1529,6 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c)
                                           sizeof (CGGlyph *) * nrows);
           cache->glyph.matrix[nrows - 1] = glyphs;
           cache->glyph.nrows = nrows;
-
-          if (group)
-            {
-              dispatch_group_wait (group, DISPATCH_TIME_FOREVER);
-              dispatch_release (group);
-            }
         }
 
       return cache->glyph.matrix[nkeys_or_perm - ROW_PERM_OFFSET][c % 256];
@@ -3267,9 +3255,6 @@ mac_font_get_glyphs_for_variants (CFDataRef uvs_table, UTF32Char c,
   struct variation_selector_record *records = uvs->variation_selector_records;
   CFIndex i;
   UInt32 ir, nrecords;
-  dispatch_queue_t queue =
-    dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
-  dispatch_group_t group = dispatch_group_create ();
 
   nrecords = BUINT32_VALUE (uvs->num_var_selector_records);
   i = 0;
@@ -3293,66 +3278,63 @@ mac_font_get_glyphs_for_variants (CFDataRef uvs_table, UTF32Char c,
       default_uvs_offset = BUINT32_VALUE (records[ir].default_uvs_offset);
       non_default_uvs_offset =
         BUINT32_VALUE (records[ir].non_default_uvs_offset);
-      dispatch_group_async (group, queue, ^{
-          glyphs[i] = kCGFontIndexInvalid;
 
-          if (default_uvs_offset)
+      glyphs[i] = kCGFontIndexInvalid;
+
+      if (default_uvs_offset)
+        {
+          struct default_uvs_table *default_uvs =
+            (struct default_uvs_table *) ((UInt8 *) uvs
+                                          + default_uvs_offset);
+          struct unicode_value_range *ranges =
+            default_uvs->unicode_value_ranges;
+          UInt32 lo, hi;
+
+          lo = 0;
+          hi = BUINT32_VALUE (default_uvs->num_unicode_value_ranges);
+          while (lo < hi)
             {
-              struct default_uvs_table *default_uvs =
-                (struct default_uvs_table *) ((UInt8 *) uvs
-                                              + default_uvs_offset);
-              struct unicode_value_range *ranges =
-                default_uvs->unicode_value_ranges;
-              UInt32 lo, hi;
-
-              lo = 0;
-              hi = BUINT32_VALUE (default_uvs->num_unicode_value_ranges);
-              while (lo < hi)
-                {
-                  UInt32 mid = (lo + hi) / 2;
+              UInt32 mid = (lo + hi) / 2;
 
-                  if (c < BUINT24_VALUE (ranges[mid].start_unicode_value))
-                    hi = mid;
-                  else
-                    lo = mid + 1;
-                }
-              if (hi > 0
-                  && (c <= (BUINT24_VALUE (ranges[hi - 1].start_unicode_value)
-                            + BUINT8_VALUE (ranges[hi - 1].additional_count))))
-                glyphs[i] = 0;
+              if (c < BUINT24_VALUE (ranges[mid].start_unicode_value))
+                hi = mid;
+              else
+                lo = mid + 1;
             }
+          if (hi > 0
+              && (c <= (BUINT24_VALUE (ranges[hi - 1].start_unicode_value)
+                        + BUINT8_VALUE (ranges[hi - 1].additional_count))))
+            glyphs[i] = 0;
+        }
 
-          if (glyphs[i] == kCGFontIndexInvalid && non_default_uvs_offset)
+      if (glyphs[i] == kCGFontIndexInvalid && non_default_uvs_offset)
+        {
+          struct non_default_uvs_table *non_default_uvs =
+            (struct non_default_uvs_table *) ((UInt8 *) uvs
+                                              + non_default_uvs_offset);
+          struct uvs_mapping *mappings = non_default_uvs->uvs_mappings;
+          UInt32 lo, hi;
+
+          lo = 0;
+          hi = BUINT32_VALUE (non_default_uvs->num_uvs_mappings);
+          while (lo < hi)
             {
-              struct non_default_uvs_table *non_default_uvs =
-                (struct non_default_uvs_table *) ((UInt8 *) uvs
-                                                  + non_default_uvs_offset);
-              struct uvs_mapping *mappings = non_default_uvs->uvs_mappings;
-              UInt32 lo, hi;
-
-              lo = 0;
-              hi = BUINT32_VALUE (non_default_uvs->num_uvs_mappings);
-              while (lo < hi)
-                {
-                  UInt32 mid = (lo + hi) / 2;
+              UInt32 mid = (lo + hi) / 2;
 
-                  if (c < BUINT24_VALUE (mappings[mid].unicode_value))
-                    hi = mid;
-                  else
-                    lo = mid + 1;
-                }
-              if (hi > 0 &&
-                  BUINT24_VALUE (mappings[hi - 1].unicode_value) == c)
-                glyphs[i] = BUINT16_VALUE (mappings[hi - 1].glyph_id);
+              if (c < BUINT24_VALUE (mappings[mid].unicode_value))
+                hi = mid;
+              else
+                lo = mid + 1;
             }
-        });
+          if (hi > 0 &&
+              BUINT24_VALUE (mappings[hi - 1].unicode_value) == c)
+            glyphs[i] = BUINT16_VALUE (mappings[hi - 1].glyph_id);
+        }
       i++;
       ir++;
     }
   while (i < count)
     glyphs[i++] = kCGFontIndexInvalid;
-  dispatch_group_wait (group, DISPATCH_TIME_FOREVER);
-  dispatch_release (group);
 }
 
 static int