TLD lookup is performed in up to three steps, which are decribed in a
code comment. For the purposes of this patch, it suffices to mention
that the last two steps involved a QStringBuilder expression.
Avoid having to build these strings by distinguishing between the
lookups using an enum instead of a string prefix. Since qt_hash()
calls can now be chained, form the hash value by hashing the prefix
character and the domain (part) separately.
Also perform the expensive fromUtf8() call only when the string prefix
(if any) matched. Once we have nothrow UTF-8/UTF-16 comparison
operators, qIsEffectiveTLD() will no longer allocate memory, and run
at full speed. Not there, yet, though.
I have full confidence that the optimizer will have field day with
this, inline all three containsTLDEntry() calls, and constant-fold the
checks inside the loop. GCC does, so I didn't try to do it by hand.
Change-Id: I1a7647ff52b6742310928ad859d851d1f0c6bdc3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>