QSvgAbstractAnimatedProperty: de-pessimize name2type


Instead of using a QHash to store the trivial mapping between QString
and Type enum, use a hand-rolled perfect hash implementation¹.

Observe that the length of the string uniquely identifies the string.
Use that to quickly index into a switch and, after checking for False
Positives, return the corresponding type.

The use of a switch instead of an array has the advantage that we can
solicit the compiler to do the calculations for us, and also detect
collisions:

If the hash was not perfect and would produce collisions, those
collisions would manifest as case labels with the same effective
value, something that every compiler will reject. So this is safe
under additions. If this algorithm causes collisions when new strings
are added in the future, it's easy to ask some AI bot for a different
algorithm.

As a side-effect, this saves 5KiB TEXT size on optimized Linux AMD64
Clang 21 C++26 builds. That's 0.8% of the total size of the library!
It also doesn't need any initialization on first run, improving
startup performance (not measured).

Amends 36a315d9cf3cafb62332dd00c3d17d0f2a096d90 (6.9).

¹ https://en.wikipedia.org/wiki/Perfect_hash_function

Task-number: QTBUG-146132
Pick-to: 6.12 6.11
Change-Id: I63311d7b75eefb562bd49a8edcba73febbd376b1
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
commitd4c2c6919d324761d4d6c323eeec1761edd82a27
parentbf44b2063eacbd2ae3f4f95bcfbf6fbe04a2c69d
authorMarc Mutz <marc.mutz@qt.io>
committerMarc Mutz <marc.mutz@qt.io>
commit timeTue, 2 Jun 2026 14:13:41 +0000