mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 04:54:58 +00:00
AK: Use fallback builtins for overflow checks in AK::Checked
If we don't have __builtin_add_overflow_p(), we can also try using __builtin_add_overflow(). This makes debug builds with Clang significantly faster since they no longer need to use the generic implementation. Same for multiplication.
This commit is contained in:
parent
9f0aa08468
commit
a264cf79c4
1 changed files with 6 additions and 0 deletions
|
@ -348,6 +348,9 @@ public:
|
||||||
{
|
{
|
||||||
#if __has_builtin(__builtin_add_overflow_p)
|
#if __has_builtin(__builtin_add_overflow_p)
|
||||||
return __builtin_add_overflow_p(u, v, (T)0);
|
return __builtin_add_overflow_p(u, v, (T)0);
|
||||||
|
#elif __has_builtin(__builtin_add_overflow)
|
||||||
|
T result;
|
||||||
|
return __builtin_add_overflow(u, v, &result);
|
||||||
#else
|
#else
|
||||||
Checked checked;
|
Checked checked;
|
||||||
checked = u;
|
checked = u;
|
||||||
|
@ -385,6 +388,9 @@ public:
|
||||||
{
|
{
|
||||||
#if __has_builtin(__builtin_mul_overflow_p)
|
#if __has_builtin(__builtin_mul_overflow_p)
|
||||||
return __builtin_mul_overflow_p(u, v, (T)0);
|
return __builtin_mul_overflow_p(u, v, (T)0);
|
||||||
|
#elif __has_builtin(__builtin_mul_overflow)
|
||||||
|
T result;
|
||||||
|
return __builtin_mul_overflow(u, v, &result);
|
||||||
#else
|
#else
|
||||||
Checked checked;
|
Checked checked;
|
||||||
checked = u;
|
checked = u;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue