[bit-set] Restructure get_min/max() in prep for adding inverted

This commit is contained in:
Behdad Esfahbod 2021-08-18 22:08:06 -06:00
parent 669b97d949
commit 18f50275ed
1 changed files with 18 additions and 8 deletions

View File

@ -713,18 +713,28 @@ struct hb_bit_set_t
} }
hb_codepoint_t get_min () const hb_codepoint_t get_min () const
{ {
unsigned int count = pages.length; unsigned count = pages.length;
for (unsigned int i = 0; i < count; i++) for (unsigned i = 0; i < count; i++)
if (!page_at (i).is_empty ()) {
return page_map[i].major * page_t::PAGE_BITS + page_at (i).get_min (); const auto& map = page_map[i];
const auto& page = pages[map.index];
if (!page.is_empty ())
return map.major * page_t::PAGE_BITS + page.get_min ();
}
return INVALID; return INVALID;
} }
hb_codepoint_t get_max () const hb_codepoint_t get_max () const
{ {
unsigned int count = pages.length; unsigned count = pages.length;
for (int i = count - 1; i >= 0; i--) for (signed i = count - 1; i >= 0; i--)
if (!page_at (i).is_empty ()) {
return page_map[(unsigned) i].major * page_t::PAGE_BITS + page_at (i).get_max (); const auto& map = page_map[(unsigned) i];
const auto& page = pages[map.index];
if (!page.is_empty ())
return map.major * page_t::PAGE_BITS + page.get_max ();
}
return INVALID; return INVALID;
} }