Improved version with quicker lookups#152
Improved version with quicker lookups#152rschwietzke wants to merge 1 commit intoHtmlUnit:masterfrom
Conversation
| elementsByName_ = new FastHashMap<>(2 * maxCode, 0.50f); | ||
|
|
||
| for (final Element element : elementsByNameForReference_.values()) { | ||
| elementsByName_.put(element.name, element); |
There was a problem hiding this comment.
i guess this line was a mistake - or?
There was a problem hiding this comment.
Which line? We need a new elementsByName_ map and we have to fill it with upper and lowercase versions. Maybe I don't see what you mean.
|
Why with the upper case version? |
Because we want to look for both versions in one go. We start with what is given (mostly lowercase, hence we add the lowercase version here too). In case what we were given is mixed case, we try later the "forcefully" lowercased version. So, whatever is given to us. Lowercase or uppercase, it should be an instant match. Only when we have mixed case, we have to fallback to lowercasing with an expensive to lowercase of the element name. If we have a miss... well... that is the cache route later. |
Less code, more speed, more inlining