[Coverage/serialize] Micro-optimize

This commit is contained in:
Behdad Esfahbod committed 2023-05-01 16:37:37 -06:00
1 parent 491f2968cd
commit af21ea359c
2 files changed
+5 -6

No files matched your search

+2 -3
View File
@@ -113,15 +113,14 @@ struct Coverage
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (this))) return_trace (false);
unsigned count = 0;
unsigned count = hb_len (glyphs);
unsigned num_ranges = 0;
hb_codepoint_t last = (hb_codepoint_t) -2;
for (auto g: glyphs)
{
if (last + 1 != g)
num_ranges++;
num_ranges++;
last = g;
count++;
}
u.format = count <= num_ranges * 3 ? 1 : 2;
+3 -3
View File
@@ -100,10 +100,10 @@ struct CoverageFormat2_4
if (last + 1 != g)
{
range++;
rangeRecord[range].first = g;
rangeRecord[range].value = count;
rangeRecord.arrayZ[range].first = g;
rangeRecord.arrayZ[range].value = count;
}
rangeRecord[range].last = g;
rangeRecord.arrayZ[range].last = g;
last = g;
count++;
}