[algs] Use __builtin_mul_overflow

Compiles to smaller binary.
pull/3885/head
Behdad Esfahbod 2 years ago
parent a10cfe3f32
commit 25adbb3825
  1. 6
      src/hb-algs.hh

@ -853,10 +853,14 @@ hb_in_ranges (T u, T lo1, T hi1, Ts... ds)
* Overflow checking.
*/
/* Consider __builtin_mul_overflow use here also */
static inline bool
hb_unsigned_mul_overflows (unsigned int count, unsigned int size)
{
#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
unsigned result;
return __builtin_mul_overflow (count, size, &result);
#endif
return (size > 0) && (count >= ((unsigned int) -1) / size);
}

Loading…
Cancel
Save