diff options
author | Alan Third <alan@idiocy.org> | 2017-12-10 10:16:25 +0000 |
---|---|---|
committer | Alan Third <alan@idiocy.org> | 2017-12-12 20:36:40 +0000 |
commit | 45099bb90ff2107c3a30aef3047c893dbf5ef249 (patch) | |
tree | e945651fd912dd952aae7b13e83717d6da0bb70c /src/macfont.m | |
parent | b0369d0536cd510e8b7120ccf04ee98c4e323b59 (diff) | |
download | emacs-45099bb90ff2107c3a30aef3047c893dbf5ef249.tar.gz |
Remove ObjC blocks (Bug#23753)
* src/macfont.m (macfont_get_glyph_for_character):
(mac_font_get_glyphs_for_variants): Inline Objective-C blocks.
(cherry picked from commit 4590f1d768adbb2120a2b02c614f7ed3b21a4a3e)
Diffstat (limited to 'src/macfont.m')
-rw-r--r-- | src/macfont.m | 128 |
1 files changed, 55 insertions, 73 deletions
diff --git a/src/macfont.m b/src/macfont.m index 97879506ba4..6985364b34e 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -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 |