[algs] Write hb_in_ranges() recursively

This commit is contained in:
Behdad Esfahbod 2022-11-21 12:37:59 -07:00
parent 2e86700e30
commit a10cfe3f32
1 changed files with 5 additions and 10 deletions

View File

@ -838,19 +838,14 @@ hb_in_range (T u, T lo, T hi)
return (T)(u - lo) <= (T)(hi - lo); return (T)(u - lo) <= (T)(hi - lo);
} }
template <typename T> static inline bool template <typename T> static inline bool
hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2) hb_in_ranges (T u, T lo1, T hi1)
{ {
return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2); return hb_in_range (u, lo1, hi1);
} }
template <typename T> static inline bool template <typename T, typename ...Ts> static inline bool
hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) hb_in_ranges (T u, T lo1, T hi1, Ts... ds)
{ {
return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2) || hb_in_range (u, lo3, hi3); return hb_in_range (u, lo1, hi1) || hb_in_ranges (u, ds...);
}
template <typename T> static inline bool
hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3, T lo4, T hi4)
{
return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2) || hb_in_range (u, lo3, hi3) || hb_in_range (u, lo4, hi4);
} }