Use as_array() and range loops in a few places
This commit is contained in:
parent
55e7f3fe32
commit
092094f705
@ -884,19 +884,17 @@ struct NonDefaultUVS : SortedArray32Of<UVSMapping>
|
|||||||
{
|
{
|
||||||
void collect_unicodes (hb_set_t *out) const
|
void collect_unicodes (hb_set_t *out) const
|
||||||
{
|
{
|
||||||
unsigned int count = len;
|
for (const auto& a : as_array ())
|
||||||
for (unsigned int i = 0; i < count; i++)
|
out->add (a.unicodeValue);
|
||||||
out->add (arrayZ[i].unicodeValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void collect_mapping (hb_set_t *unicodes, /* OUT */
|
void collect_mapping (hb_set_t *unicodes, /* OUT */
|
||||||
hb_map_t *mapping /* OUT */) const
|
hb_map_t *mapping /* OUT */) const
|
||||||
{
|
{
|
||||||
unsigned count = len;
|
for (const auto& a : as_array ())
|
||||||
for (unsigned i = 0; i < count; i++)
|
|
||||||
{
|
{
|
||||||
hb_codepoint_t unicode = arrayZ[i].unicodeValue;
|
hb_codepoint_t unicode = a.unicodeValue;
|
||||||
hb_codepoint_t glyphid = arrayZ[i].glyphID;
|
hb_codepoint_t glyphid = a.glyphID;
|
||||||
unicodes->add (unicode);
|
unicodes->add (unicode);
|
||||||
mapping->set (unicode, glyphid);
|
mapping->set (unicode, glyphid);
|
||||||
}
|
}
|
||||||
@ -1062,9 +1060,8 @@ struct CmapSubtableFormat14
|
|||||||
|
|
||||||
void collect_variation_selectors (hb_set_t *out) const
|
void collect_variation_selectors (hb_set_t *out) const
|
||||||
{
|
{
|
||||||
unsigned int count = record.len;
|
for (const auto& a : record.as_array ())
|
||||||
for (unsigned int i = 0; i < count; i++)
|
out->add (a.varSelector);
|
||||||
out->add (record.arrayZ[i].varSelector);
|
|
||||||
}
|
}
|
||||||
void collect_variation_unicodes (hb_codepoint_t variation_selector,
|
void collect_variation_unicodes (hb_codepoint_t variation_selector,
|
||||||
hb_set_t *out) const
|
hb_set_t *out) const
|
||||||
|
@ -557,7 +557,7 @@ struct IndexArray : Array16Of<Index>
|
|||||||
|
|
||||||
void add_indexes_to (hb_set_t* output /* OUT */) const
|
void add_indexes_to (hb_set_t* output /* OUT */) const
|
||||||
{
|
{
|
||||||
output->add_array (arrayZ, len);
|
output->add_array (as_array ());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1406,10 +1406,8 @@ struct CoverageFormat1
|
|||||||
bool intersects (const hb_set_t *glyphs) const
|
bool intersects (const hb_set_t *glyphs) const
|
||||||
{
|
{
|
||||||
/* TODO Speed up, using hb_set_next() and bsearch()? */
|
/* TODO Speed up, using hb_set_next() and bsearch()? */
|
||||||
unsigned int count = glyphArray.len;
|
for (const auto& g : glyphArray.as_array ())
|
||||||
const HBGlyphID *arr = glyphArray.arrayZ;
|
if (glyphs->has (g))
|
||||||
for (unsigned int i = 0; i < count; i++)
|
|
||||||
if (glyphs->has (arr[i]))
|
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1426,7 +1424,7 @@ struct CoverageFormat1
|
|||||||
|
|
||||||
template <typename set_t>
|
template <typename set_t>
|
||||||
bool collect_coverage (set_t *glyphs) const
|
bool collect_coverage (set_t *glyphs) const
|
||||||
{ return glyphs->add_sorted_array (glyphArray.arrayZ, glyphArray.len); }
|
{ return glyphs->add_sorted_array (glyphArray.as_array ()); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Older compilers need this to be public. */
|
/* Older compilers need this to be public. */
|
||||||
@ -1522,20 +1520,16 @@ struct CoverageFormat2
|
|||||||
{
|
{
|
||||||
/* TODO Speed up, using hb_set_next() and bsearch()? */
|
/* TODO Speed up, using hb_set_next() and bsearch()? */
|
||||||
/* TODO(iter) Rewrite as dagger. */
|
/* TODO(iter) Rewrite as dagger. */
|
||||||
unsigned count = rangeRecord.len;
|
for (const auto& range : rangeRecord.as_array ())
|
||||||
const RangeRecord *arr = rangeRecord.arrayZ;
|
if (range.intersects (glyphs))
|
||||||
for (unsigned i = 0; i < count; i++)
|
|
||||||
if (arr[i].intersects (glyphs))
|
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const
|
bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const
|
||||||
{
|
{
|
||||||
/* TODO(iter) Rewrite as dagger. */
|
/* TODO(iter) Rewrite as dagger. */
|
||||||
unsigned count = rangeRecord.len;
|
for (const auto& range : rangeRecord.as_array ())
|
||||||
const RangeRecord *arr = rangeRecord.arrayZ;
|
{
|
||||||
for (unsigned i = 0; i < count; i++) {
|
|
||||||
const RangeRecord &range = arr[i];
|
|
||||||
if (range.value <= index &&
|
if (range.value <= index &&
|
||||||
index < (unsigned int) range.value + (range.last - range.first) &&
|
index < (unsigned int) range.value + (range.last - range.first) &&
|
||||||
range.intersects (glyphs))
|
range.intersects (glyphs))
|
||||||
@ -1548,10 +1542,8 @@ struct CoverageFormat2
|
|||||||
|
|
||||||
void intersected_coverage_glyphs (const hb_set_t *glyphs, hb_set_t *intersect_glyphs) const
|
void intersected_coverage_glyphs (const hb_set_t *glyphs, hb_set_t *intersect_glyphs) const
|
||||||
{
|
{
|
||||||
unsigned count = rangeRecord.len;
|
for (const auto& range : rangeRecord.as_array ())
|
||||||
for (unsigned i = 0; i < count; i++)
|
|
||||||
{
|
{
|
||||||
const RangeRecord &range = rangeRecord[i];
|
|
||||||
if (!range.intersects (glyphs)) continue;
|
if (!range.intersects (glyphs)) continue;
|
||||||
for (hb_codepoint_t g = range.first; g <= range.last; g++)
|
for (hb_codepoint_t g = range.first; g <= range.last; g++)
|
||||||
if (glyphs->has (g)) intersect_glyphs->add (g);
|
if (glyphs->has (g)) intersect_glyphs->add (g);
|
||||||
|
@ -337,6 +337,8 @@ struct hb_set_t
|
|||||||
while (count && (g = *array, start <= g && g < end));
|
while (count && (g = *array, start <= g && g < end));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
template <typename T>
|
||||||
|
void add_array (const hb_array_t<const T>& arr) { add_array (&arr, arr.len ()); }
|
||||||
|
|
||||||
/* Might return false if array looks unsorted.
|
/* Might return false if array looks unsorted.
|
||||||
* Used for faster rejection of corrupt data. */
|
* Used for faster rejection of corrupt data. */
|
||||||
@ -368,6 +370,8 @@ struct hb_set_t
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
template <typename T>
|
||||||
|
bool add_sorted_array (const hb_sorted_array_t<const T>& arr) { return add_sorted_array (&arr, arr.len ()); }
|
||||||
|
|
||||||
void del (hb_codepoint_t g)
|
void del (hb_codepoint_t g)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user