[subset] In cmap4 serialization reduce unnessecary calls into the iterator.

Gives ~20% speedup for large subsets.
This commit is contained in:
Garret Rieger 2022-04-29 22:49:02 +00:00
parent 5e241094bf
commit 17b98563dc
1 changed files with 16 additions and 12 deletions

View File

@ -109,22 +109,26 @@ struct CmapSubtableFormat4
while (it) { while (it) {
// Start a new range // Start a new range
start_cp = (*it).first; {
prev_run_start_cp = (*it).first; const auto& pair = *it;
run_start_cp = (*it).first; start_cp = pair.first;
end_cp = (*it).first; prev_run_start_cp = start_cp;
last_gid = (*it).second; run_start_cp = start_cp;
end_cp = start_cp;
last_gid = pair.second;
run_length = 1; run_length = 1;
prev_delta = 0; prev_delta = 0;
}
delta = (*it).second - (*it).first; delta = last_gid - start_cp;
mode = FIRST_SUB_RANGE; mode = FIRST_SUB_RANGE;
it++; it++;
while (it) { while (it) {
// Process range // Process range
hb_codepoint_t next_cp = (*it).first; const auto& pair = *it;
hb_codepoint_t next_gid = (*it).second; hb_codepoint_t next_cp = pair.first;
hb_codepoint_t next_gid = pair.second;
if (next_cp != end_cp + 1) { if (next_cp != end_cp + 1) {
// Current range is over, stop processing. // Current range is over, stop processing.
break; break;
@ -323,7 +327,7 @@ struct CmapSubtableFormat4
{ return _.first <= 0xFFFF; }) { return _.first <= 0xFFFF; })
; ;
if (format4_iter.len () == 0) return; if (!format4_iter) return;
unsigned table_initpos = c->length (); unsigned table_initpos = c->length ();
if (unlikely (!c->extend_min (this))) return; if (unlikely (!c->extend_min (this))) return;
@ -1474,7 +1478,7 @@ struct SubtableUnicodesCache {
hb_set_t* new_set = hb_set_create (); hb_set_t* new_set = hb_set_create ();
if (!cached_unicodes.set ((intptr_t) record, new_set)) { if (!cached_unicodes.set ((intptr_t) record, new_set)) {
hb_set_destroy (new_set); hb_set_destroy (new_set);
return hb_set_empty (); return hb_set_get_empty ();
} }
(base+record->subtable).collect_unicodes (cached_unicodes.get ((intptr_t) record)); (base+record->subtable).collect_unicodes (cached_unicodes.get ((intptr_t) record));
} }