1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

AK: Use compiler builtins for MakeIntegerSequence/TypeListElement

These recursive templates have a measurable impact on the compile speed
of Variant-heavy code like LibWeb. Using these builtins leads to a 2.5%
speedup for the measured compilation units.
This commit is contained in:
Daniel Bertalan 2023-06-27 07:48:39 +02:00 committed by Andreas Kling
parent 4596d41291
commit 1a10e904b5
2 changed files with 15 additions and 0 deletions

View file

@ -454,6 +454,13 @@ struct IntegerSequence {
template<unsigned... Indices>
using IndexSequence = IntegerSequence<unsigned, Indices...>;
#if __has_builtin(__make_integer_seq)
template<typename T, T N>
using MakeIntegerSequence = __make_integer_seq<IntegerSequence, T, N>;
#elif __has_builtin(__integer_pack)
template<typename T, T N>
using MakeIntegerSequence = IntegerSequence<T, __integer_pack(N)...>;
#else
template<typename T, T N, T... Ts>
auto make_integer_sequence_impl()
{
@ -465,6 +472,7 @@ auto make_integer_sequence_impl()
template<typename T, T N>
using MakeIntegerSequence = decltype(make_integer_sequence_impl<T, N>());
#endif
template<unsigned N>
using MakeIndexSequence = MakeIntegerSequence<unsigned, N>;