gnodet commented on PR #2956:
URL: https://github.com/apache/cxf/pull/2956#issuecomment-4050387945

   Looking at this more carefully, the change from `TreeMap` to `HashMap` is 
correct and the `Comparable` on `MatcherHolder` was effectively dead code. 
Here's why:
   
   The `TreeMap<String, List<MatcherHolder>>` is keyed by **class name** — the 
`TreeMap` sorts by that key (alphabetical class name order), which has no 
semantic meaning for the matching logic.
   
   The `MatcherHolder.compareTo()` method was designed to prioritize patterns 
with more literal characters, but it was never actually used: the holders are 
stored in an `ArrayList<MatcherHolder>`, which doesn't use `Comparable` to 
maintain order. Items are always matched in insertion order regardless.
   
   So both the `TreeMap` ordering and `MatcherHolder.compareTo()` were dead 
code — the `HashMap` + `PatternHolder` replacement is a correct simplification.
   
   The other changes (reusing `Pattern` instead of `Matcher`, dropping 
`synchronized`, using `computeIfAbsent`) are also improvements — `Pattern` is 
thread-safe and immutable, while `Matcher` is not, which is why the old code 
needed `synchronized (m.matcher)`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to