2 * Copyright © 2012,2017 Google, Inc.
3 * Copyright © 2021 Behdad Esfahbod
5 * This is part of HarfBuzz, a text shaping library.
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 * Google Author(s): Behdad Esfahbod
32 #include "hb-bit-page.hh"
37 hb_bit_set_t () = default;
38 ~hb_bit_set_t () = default;
40 hb_bit_set_t (const hb_bit_set_t& other) : hb_bit_set_t () { set (other, true); }
41 hb_bit_set_t ( hb_bit_set_t&& other) : hb_bit_set_t () { hb_swap (*this, other); }
42 hb_bit_set_t& operator= (const hb_bit_set_t& other) { set (other); return *this; }
43 hb_bit_set_t& operator= (hb_bit_set_t&& other) { hb_swap (*this, other); return *this; }
44 friend void swap (hb_bit_set_t &a, hb_bit_set_t &b)
46 if (likely (!a.successful || !b.successful))
48 hb_swap (a.population, b.population);
49 hb_swap (a.last_page_lookup, b.last_page_lookup);
50 hb_swap (a.page_map, b.page_map);
51 hb_swap (a.pages, b.pages);
68 using page_t = hb_bit_page_t;
71 int cmp (const page_map_t &o) const { return cmp (o.major); }
72 int cmp (uint32_t o_major) const { return (int) o_major - (int) major; }
78 bool successful = true; /* Allocations successful */
79 mutable unsigned int population = 0;
80 mutable hb_atomic_int_t last_page_lookup = 0;
81 hb_sorted_vector_t<page_map_t> page_map;
82 hb_vector_t<page_t> pages;
84 void err () { if (successful) successful = false; } /* TODO Remove */
85 bool in_error () const { return !successful; }
87 bool resize (unsigned int count, bool clear = true, bool exact_size = false)
89 if (unlikely (!successful)) return false;
91 if (pages.length == 0 && count == 1)
92 exact_size = true; // Most sets are small and local
94 if (unlikely (!pages.resize (count, clear, exact_size) || !page_map.resize (count, clear, exact_size)))
96 pages.resize (page_map.length, clear, exact_size);
103 void alloc (unsigned sz)
105 sz >>= (page_t::PAGE_BITS_LOG_2 - 1);
119 if (likely (successful))
122 bool is_empty () const
124 unsigned int count = pages.length;
125 for (unsigned int i = 0; i < count; i++)
126 if (!pages[i].is_empty ())
130 explicit operator bool () const { return !is_empty (); }
132 uint32_t hash () const
135 for (auto &map : page_map)
137 auto &page = pages.arrayZ[map.index];
138 if (unlikely (page.is_empty ())) continue;
139 h = h * 31 + hb_hash (map.major) + hb_hash (page);
145 void dirty () { population = UINT_MAX; }
148 void add (hb_codepoint_t g)
150 if (unlikely (!successful)) return;
151 if (unlikely (g == INVALID)) return;
153 page_t *page = page_for (g, true); if (unlikely (!page)) return;
156 bool add_range (hb_codepoint_t a, hb_codepoint_t b)
158 if (unlikely (!successful)) return true; /* https://github.com/harfbuzz/harfbuzz/issues/657 */
159 if (unlikely (a > b || a == INVALID || b == INVALID)) return false;
161 unsigned int ma = get_major (a);
162 unsigned int mb = get_major (b);
165 page_t *page = page_for (a, true); if (unlikely (!page)) return false;
166 page->add_range (a, b);
170 page_t *page = page_for (a, true); if (unlikely (!page)) return false;
171 page->add_range (a, major_start (ma + 1) - 1);
173 for (unsigned int m = ma + 1; m < mb; m++)
175 page = page_for (major_start (m), true); if (unlikely (!page)) return false;
179 page = page_for (b, true); if (unlikely (!page)) return false;
180 page->add_range (major_start (mb), b);
185 /* Duplicated here from hb-machinery.hh to avoid including it. */
186 template<typename Type>
187 static inline const Type& StructAtOffsetUnaligned(const void *P, unsigned int offset)
189 #pragma GCC diagnostic push
190 #pragma GCC diagnostic ignored "-Wcast-align"
191 return * reinterpret_cast<const Type*> ((const char *) P + offset);
192 #pragma GCC diagnostic pop
195 template <typename T>
196 void set_array (bool v, const T *array, unsigned int count, unsigned int stride=sizeof(T))
198 if (unlikely (!successful)) return;
201 hb_codepoint_t g = *array;
204 unsigned int m = get_major (g);
205 page_t *page = page_for (g, v); if (unlikely (v && !page)) return;
206 unsigned int start = major_start (m);
207 unsigned int end = major_start (m + 1);
210 if (g != INVALID && (v || page)) /* The v check is to optimize out the page check if v is true. */
213 array = &StructAtOffsetUnaligned<T> (array, stride);
216 while (count && (g = *array, start <= g && g < end));
220 template <typename T>
221 void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T))
222 { set_array (true, array, count, stride); }
223 template <typename T>
224 void add_array (const hb_array_t<const T>& arr) { add_array (&arr, arr.len ()); }
226 template <typename T>
227 void del_array (const T *array, unsigned int count, unsigned int stride=sizeof(T))
228 { set_array (false, array, count, stride); }
229 template <typename T>
230 void del_array (const hb_array_t<const T>& arr) { del_array (&arr, arr.len ()); }
232 /* Might return false if array looks unsorted.
233 * Used for faster rejection of corrupt data. */
234 template <typename T>
235 bool set_sorted_array (bool v, const T *array, unsigned int count, unsigned int stride=sizeof(T))
237 if (unlikely (!successful)) return true; /* https://github.com/harfbuzz/harfbuzz/issues/657 */
238 if (unlikely (!count)) return true;
240 hb_codepoint_t g = *array;
241 hb_codepoint_t last_g = g;
244 unsigned int m = get_major (g);
245 page_t *page = page_for (g, v); if (unlikely (v && !page)) return false;
246 unsigned int end = major_start (m + 1);
249 /* If we try harder we can change the following comparison to <=;
250 * Not sure if it's worth it. */
251 if (g < last_g) return false;
254 if (g != INVALID && (v || page)) /* The v check is to optimize out the page check if v is true. */
257 array = &StructAtOffsetUnaligned<T> (array, stride);
260 while (count && (g = *array, g < end));
265 template <typename T>
266 bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T))
267 { return set_sorted_array (true, array, count, stride); }
268 template <typename T>
269 bool add_sorted_array (const hb_sorted_array_t<const T>& arr) { return add_sorted_array (&arr, arr.len ()); }
271 template <typename T>
272 bool del_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T))
273 { return set_sorted_array (false, array, count, stride); }
274 template <typename T>
275 bool del_sorted_array (const hb_sorted_array_t<const T>& arr) { return del_sorted_array (&arr, arr.len ()); }
277 void del (hb_codepoint_t g)
279 if (unlikely (!successful)) return;
280 page_t *page = page_for (g);
288 void del_pages (int ds, int de)
292 // Pre-allocate the workspace that compact() will need so we can bail on allocation failure
293 // before attempting to rewrite the page map.
294 hb_vector_t<unsigned> compact_workspace;
295 if (unlikely (!allocate_compact_workspace (compact_workspace))) return;
297 unsigned int write_index = 0;
298 for (unsigned int i = 0; i < page_map.length; i++)
300 int m = (int) page_map[i].major;
301 if (m < ds || de < m)
302 page_map[write_index++] = page_map[i];
304 compact (compact_workspace, write_index);
305 resize (write_index);
311 void del_range (hb_codepoint_t a, hb_codepoint_t b)
313 if (unlikely (!successful)) return;
314 if (unlikely (a > b || a == INVALID)) return;
316 unsigned int ma = get_major (a);
317 unsigned int mb = get_major (b);
318 /* Delete pages from ds through de if ds <= de. */
319 int ds = (a == major_start (ma))? (int) ma: (int) (ma + 1);
320 int de = (b + 1 == major_start (mb + 1))? (int) mb: ((int) mb - 1);
321 if (ds > de || (int) ma < ds)
323 page_t *page = page_for (a);
327 page->del_range (a, b);
329 page->del_range (a, major_start (ma + 1) - 1);
332 if (de < (int) mb && ma != mb)
334 page_t *page = page_for (b);
336 page->del_range (major_start (mb), b);
341 bool get (hb_codepoint_t g) const
343 const page_t *page = page_for (g);
346 return page->get (g);
350 bool operator [] (hb_codepoint_t k) const { return get (k); }
351 bool has (hb_codepoint_t k) const { return (*this)[k]; }
353 bool operator () (hb_codepoint_t k) const { return has (k); }
355 /* Sink interface. */
356 hb_bit_set_t& operator << (hb_codepoint_t v)
357 { add (v); return *this; }
358 hb_bit_set_t& operator << (const hb_codepoint_pair_t& range)
359 { add_range (range.first, range.second); return *this; }
361 bool intersects (hb_codepoint_t first, hb_codepoint_t last) const
363 hb_codepoint_t c = first - 1;
364 return next (&c) && c <= last;
366 void set (const hb_bit_set_t &other, bool exact_size = false)
368 if (unlikely (!successful)) return;
369 unsigned int count = other.pages.length;
370 if (unlikely (!resize (count, false, exact_size)))
372 population = other.population;
374 page_map = other.page_map;
378 bool is_equal (const hb_bit_set_t &other) const
380 if (has_population () && other.has_population () &&
381 population != other.population)
384 unsigned int na = pages.length;
385 unsigned int nb = other.pages.length;
387 unsigned int a = 0, b = 0;
388 for (; a < na && b < nb; )
390 if (page_at (a).is_empty ()) { a++; continue; }
391 if (other.page_at (b).is_empty ()) { b++; continue; }
392 if (page_map[a].major != other.page_map[b].major ||
393 !page_at (a).is_equal (other.page_at (b)))
399 if (!page_at (a).is_empty ()) { return false; }
401 if (!other.page_at (b).is_empty ()) { return false; }
406 bool is_subset (const hb_bit_set_t &larger_set) const
408 if (has_population () && larger_set.has_population () &&
409 population > larger_set.population)
413 for (uint32_t lpi = 0; spi < page_map.length && lpi < larger_set.page_map.length; lpi++)
415 uint32_t spm = page_map[spi].major;
416 uint32_t lpm = larger_set.page_map[lpi].major;
417 auto sp = page_at (spi);
419 if (spm < lpm && !sp.is_empty ())
425 auto lp = larger_set.page_at (lpi);
426 if (!sp.is_subset (lp))
432 while (spi < page_map.length)
433 if (!page_at (spi++).is_empty ())
440 bool allocate_compact_workspace (hb_vector_t<unsigned>& workspace)
442 if (unlikely (!workspace.resize_exact (pages.length)))
452 * workspace should be a pre-sized vector allocated to hold at exactly pages.length
455 void compact (hb_vector_t<unsigned>& workspace,
458 assert(workspace.length == pages.length);
459 hb_vector_t<unsigned>& old_index_to_page_map_index = workspace;
461 hb_fill (old_index_to_page_map_index.writer(), 0xFFFFFFFF);
462 for (unsigned i = 0; i < length; i++)
463 old_index_to_page_map_index[page_map[i].index] = i;
465 compact_pages (old_index_to_page_map_index);
467 void compact_pages (const hb_vector_t<unsigned>& old_index_to_page_map_index)
469 unsigned int write_index = 0;
470 for (unsigned int i = 0; i < pages.length; i++)
472 if (old_index_to_page_map_index[i] == 0xFFFFFFFF) continue;
475 pages[write_index] = pages[i];
477 page_map[old_index_to_page_map_index[i]].index = write_index;
483 void process_ (hb_bit_page_t::vector_t (*op) (const hb_bit_page_t::vector_t &, const hb_bit_page_t::vector_t &),
484 bool passthru_left, bool passthru_right,
485 const hb_bit_set_t &other)
487 if (unlikely (!successful)) return;
491 unsigned int na = pages.length;
492 unsigned int nb = other.pages.length;
493 unsigned int next_page = na;
495 unsigned int count = 0, newCount = 0;
496 unsigned int a = 0, b = 0;
497 unsigned int write_index = 0;
499 // Pre-allocate the workspace that compact() will need so we can bail on allocation failure
500 // before attempting to rewrite the page map.
501 hb_vector_t<unsigned> compact_workspace;
502 if (!passthru_left && unlikely (!allocate_compact_workspace (compact_workspace))) return;
504 for (; a < na && b < nb; )
506 if (page_map[a].major == other.page_map[b].major)
510 // Move page_map entries that we're keeping from the left side set
511 // to the front of the page_map vector. This isn't necessary if
512 // passthru_left is set since no left side pages will be removed
515 page_map[write_index] = page_map[a];
523 else if (page_map[a].major < other.page_map[b].major)
544 next_page = write_index;
545 compact (compact_workspace, write_index);
548 if (unlikely (!resize (count)))
553 /* Process in-place backward. */
558 if (page_map.arrayZ[a - 1].major == other.page_map.arrayZ[b - 1].major)
563 page_map.arrayZ[count] = page_map.arrayZ[a];
564 page_at (count).v = op (page_at (a).v, other.page_at (b).v);
565 page_at (count).dirty ();
567 else if (page_map.arrayZ[a - 1].major > other.page_map.arrayZ[b - 1].major)
573 page_map.arrayZ[count] = page_map.arrayZ[a];
582 page_map.arrayZ[count].major = other.page_map.arrayZ[b].major;
583 page_map.arrayZ[count].index = next_page++;
584 page_at (count) = other.page_at (b);
593 page_map.arrayZ[count] = page_map.arrayZ[a];
600 page_map.arrayZ[count].major = other.page_map.arrayZ[b].major;
601 page_map.arrayZ[count].index = next_page++;
602 page_at (count) = other.page_at (b);
607 template <typename Op>
608 static hb_bit_page_t::vector_t
609 op_ (const hb_bit_page_t::vector_t &a, const hb_bit_page_t::vector_t &b)
610 { return Op{} (a, b); }
611 template <typename Op>
612 void process (const Op& op, const hb_bit_set_t &other)
614 process_ (op_<Op>, op (1, 0), op (0, 1), other);
617 void union_ (const hb_bit_set_t &other) { process (hb_bitwise_or, other); }
618 void intersect (const hb_bit_set_t &other) { process (hb_bitwise_and, other); }
619 void subtract (const hb_bit_set_t &other) { process (hb_bitwise_gt, other); }
620 void symmetric_difference (const hb_bit_set_t &other) { process (hb_bitwise_xor, other); }
622 bool next (hb_codepoint_t *codepoint) const
624 if (unlikely (*codepoint == INVALID)) {
625 *codepoint = get_min ();
626 return *codepoint != INVALID;
629 const auto* page_map_array = page_map.arrayZ;
630 unsigned int major = get_major (*codepoint);
631 unsigned int i = last_page_lookup;
633 if (unlikely (i >= page_map.length || page_map_array[i].major != major))
635 page_map.bfind (major, &i, HB_NOT_FOUND_STORE_CLOSEST);
636 if (i >= page_map.length) {
637 *codepoint = INVALID;
640 last_page_lookup = i;
643 const auto* pages_array = pages.arrayZ;
644 const page_map_t ¤t = page_map_array[i];
645 if (likely (current.major == major))
647 if (pages_array[current.index].next (codepoint))
649 *codepoint += current.major * page_t::PAGE_BITS;
655 for (; i < page_map.length; i++)
657 const page_map_t ¤t = page_map_array[i];
658 hb_codepoint_t m = pages_array[current.index].get_min ();
661 *codepoint = current.major * page_t::PAGE_BITS + m;
662 last_page_lookup = i;
666 *codepoint = INVALID;
669 bool previous (hb_codepoint_t *codepoint) const
671 if (unlikely (*codepoint == INVALID)) {
672 *codepoint = get_max ();
673 return *codepoint != INVALID;
676 page_map_t map = {get_major (*codepoint), 0};
678 page_map.bfind (map, &i, HB_NOT_FOUND_STORE_CLOSEST);
679 if (i < page_map.length && page_map.arrayZ[i].major == map.major)
681 if (pages[page_map.arrayZ[i].index].previous (codepoint))
683 *codepoint += page_map.arrayZ[i].major * page_t::PAGE_BITS;
688 for (; (int) i >= 0; i--)
690 hb_codepoint_t m = pages.arrayZ[page_map.arrayZ[i].index].get_max ();
693 *codepoint = page_map.arrayZ[i].major * page_t::PAGE_BITS + m;
697 *codepoint = INVALID;
700 bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const
707 *last = *first = INVALID;
713 while (next (&i) && i == *last + 1)
718 bool previous_range (hb_codepoint_t *first, hb_codepoint_t *last) const
725 *last = *first = INVALID;
731 while (previous (&i) && i == *first - 1)
737 unsigned int next_many (hb_codepoint_t codepoint,
739 unsigned int size) const
741 // By default, start at the first bit of the first page of values.
742 unsigned int start_page = 0;
743 unsigned int start_page_value = 0;
744 if (unlikely (codepoint != INVALID))
746 const auto* page_map_array = page_map.arrayZ;
747 unsigned int major = get_major (codepoint);
748 unsigned int i = last_page_lookup;
749 if (unlikely (i >= page_map.length || page_map_array[i].major != major))
751 page_map.bfind (major, &i, HB_NOT_FOUND_STORE_CLOSEST);
752 if (i >= page_map.length)
753 return 0; // codepoint is greater than our max element.
756 start_page_value = page_remainder (codepoint + 1);
757 if (unlikely (start_page_value == 0))
759 // The export-after value was last in the page. Start on next page.
761 start_page_value = 0;
765 unsigned int initial_size = size;
766 for (unsigned int i = start_page; i < page_map.length && size; i++)
768 uint32_t base = major_start (page_map[i].major);
769 unsigned int n = pages[page_map[i].index].write (base, start_page_value, out, size);
772 start_page_value = 0;
774 return initial_size - size;
777 unsigned int next_many_inverted (hb_codepoint_t codepoint,
779 unsigned int size) const
781 unsigned int initial_size = size;
782 // By default, start at the first bit of the first page of values.
783 unsigned int start_page = 0;
784 unsigned int start_page_value = 0;
785 if (unlikely (codepoint != INVALID))
787 const auto* page_map_array = page_map.arrayZ;
788 unsigned int major = get_major (codepoint);
789 unsigned int i = last_page_lookup;
790 if (unlikely (i >= page_map.length || page_map_array[i].major != major))
792 page_map.bfind(major, &i, HB_NOT_FOUND_STORE_CLOSEST);
793 if (unlikely (i >= page_map.length))
795 // codepoint is greater than our max element.
796 while (++codepoint != INVALID && size)
801 return initial_size - size;
805 start_page_value = page_remainder (codepoint + 1);
806 if (unlikely (start_page_value == 0))
808 // The export-after value was last in the page. Start on next page.
810 start_page_value = 0;
814 hb_codepoint_t next_value = codepoint + 1;
815 for (unsigned int i=start_page; i<page_map.length && size; i++)
817 uint32_t base = major_start (page_map[i].major);
818 unsigned int n = pages[page_map[i].index].write_inverted (base, start_page_value, out, size, &next_value);
821 start_page_value = 0;
823 while (next_value < HB_SET_VALUE_INVALID && size) {
824 *out++ = next_value++;
827 return initial_size - size;
830 bool has_population () const { return population != UINT_MAX; }
831 unsigned int get_population () const
833 if (has_population ())
836 unsigned int pop = 0;
837 unsigned int count = pages.length;
838 for (unsigned int i = 0; i < count; i++)
839 pop += pages[i].get_population ();
844 hb_codepoint_t get_min () const
846 unsigned count = pages.length;
847 for (unsigned i = 0; i < count; i++)
849 const auto& map = page_map[i];
850 const auto& page = pages[map.index];
852 if (!page.is_empty ())
853 return map.major * page_t::PAGE_BITS + page.get_min ();
857 hb_codepoint_t get_max () const
859 unsigned count = pages.length;
860 for (signed i = count - 1; i >= 0; i--)
862 const auto& map = page_map[(unsigned) i];
863 const auto& page = pages[map.index];
865 if (!page.is_empty ())
866 return map.major * page_t::PAGE_BITS + page.get_max ();
871 static constexpr hb_codepoint_t INVALID = page_t::INVALID;
874 * Iterator implementation.
876 struct iter_t : hb_iter_with_fallback_t<iter_t, hb_codepoint_t>
878 static constexpr bool is_sorted_iterator = true;
879 static constexpr bool has_fast_len = true;
880 iter_t (const hb_bit_set_t &s_ = Null (hb_bit_set_t),
881 bool init = true) : s (&s_), v (INVALID), l(0)
885 l = s->get_population () + 1;
890 typedef hb_codepoint_t __item_t__;
891 hb_codepoint_t __item__ () const { return v; }
892 bool __more__ () const { return v != INVALID; }
893 void __next__ () { s->next (&v); if (l) l--; }
894 void __prev__ () { s->previous (&v); }
895 unsigned __len__ () const { return l; }
896 iter_t end () const { return iter_t (*s, false); }
897 bool operator != (const iter_t& o) const
898 { return s != o.s || v != o.v; }
901 const hb_bit_set_t *s;
905 iter_t iter () const { return iter_t (*this); }
906 operator iter_t () const { return iter (); }
910 page_t *page_for (hb_codepoint_t g, bool insert = false)
912 unsigned major = get_major (g);
914 /* The extra page_map length is necessary; can't just rely on vector here,
915 * since the next check would be tricked because a null page also has
916 * major==0, which we can't distinguish from an actually major==0 page... */
917 unsigned i = last_page_lookup;
918 if (likely (i < page_map.length))
920 auto &cached_page = page_map.arrayZ[i];
921 if (cached_page.major == major)
922 return &pages.arrayZ[cached_page.index];
925 page_map_t map = {major, pages.length};
926 if (!page_map.bfind (map, &i, HB_NOT_FOUND_STORE_CLOSEST))
931 if (unlikely (!resize (pages.length + 1)))
934 pages.arrayZ[map.index].init0 ();
935 memmove (page_map.arrayZ + i + 1,
937 (page_map.length - 1 - i) * page_map.item_size);
938 page_map.arrayZ[i] = map;
941 last_page_lookup = i;
942 return &pages.arrayZ[page_map.arrayZ[i].index];
944 const page_t *page_for (hb_codepoint_t g) const
946 unsigned major = get_major (g);
948 /* The extra page_map length is necessary; can't just rely on vector here,
949 * since the next check would be tricked because a null page also has
950 * major==0, which we can't distinguish from an actually major==0 page... */
951 unsigned i = last_page_lookup;
952 if (likely (i < page_map.length))
954 auto &cached_page = page_map.arrayZ[i];
955 if (cached_page.major == major)
956 return &pages.arrayZ[cached_page.index];
959 page_map_t key = {major};
960 if (!page_map.bfind (key, &i))
963 last_page_lookup = i;
964 return &pages.arrayZ[page_map[i].index];
966 page_t &page_at (unsigned int i)
968 assert (i < page_map.length);
969 return pages.arrayZ[page_map.arrayZ[i].index];
971 const page_t &page_at (unsigned int i) const
973 assert (i < page_map.length);
974 return pages.arrayZ[page_map.arrayZ[i].index];
976 unsigned int get_major (hb_codepoint_t g) const { return g >> page_t::PAGE_BITS_LOG_2; }
977 unsigned int page_remainder (hb_codepoint_t g) const { return g & page_t::PAGE_BITMASK; }
978 hb_codepoint_t major_start (unsigned int major) const { return major << page_t::PAGE_BITS_LOG_2; }
982 #endif /* HB_BIT_SET_HH */