diff --git a/AK/Checked.h b/AK/Checked.h index 9514a8fb9d..ac98519678 100644 --- a/AK/Checked.h +++ b/AK/Checked.h @@ -234,13 +234,16 @@ public: return *this; } + template + static bool addition_would_overflow(U u, V v) + { + return __builtin_add_overflow_p(u, v, (T)0); + } + template static bool multiplication_would_overflow(U u, V v) { - Checked checked; - checked = u; - checked *= v; - return checked.has_overflow(); + return __builtin_mul_overflow_p(u, v, (T)0); } template