Date: Mon, 20 Apr 2026 16:14:37 +0200
On 4/20/26 15:29, Muneem via Std-Proposals wrote:
> The issue with your code is that it keeps on making arrays on the fly. I
> know the compiler has no issue optimizing it but relying on
> optimizations isn't a positive thing, like vectors provide complexity
> gurreenties instead of relying on optimizations. In your case the
> complexity of is O(N) because you keep on making an array on the fly.
> Further more the indexes that you used were constexpr not runtime. In my
Let me modify my code slightly so it does not optimize the look-up table
away:
https://godbolt.org/z/Eo5GosPMj
The lookup table is constructed at compile-time and stored globally
in line 42 of the assembly output. There is no on-the-fly construction.
> The issue with your code is that it keeps on making arrays on the fly. I
> know the compiler has no issue optimizing it but relying on
> optimizations isn't a positive thing, like vectors provide complexity
> gurreenties instead of relying on optimizations. In your case the
> complexity of is O(N) because you keep on making an array on the fly.
> Further more the indexes that you used were constexpr not runtime. In my
Let me modify my code slightly so it does not optimize the look-up table
away:
https://godbolt.org/z/Eo5GosPMj
The lookup table is constructed at compile-time and stored globally
in line 42 of the assembly output. There is no on-the-fly construction.
Received on 2026-04-20 14:14:40
