On Fri, 6 Oct 2023 20:55:40 GMT, 温绍锦 <d...@openjdk.org> wrote: > @cl4es and @Glavo have already made some very good optimizations to > URLEncoder, but we can continue to improve. > > The current URLEncoder's Predicate for DONT_NEED_ENCODING is based on BitSet, > which is actually a table lookup. The actual performance may not be as good > as microbench. > > The character value range of DONT_NEED_ENCODING is between [45-122]. We can > construct two long type constants to do the work of BitSet. This can improve > performance by about 7% to 30%.
It was recently conceived specifically to help `URLEncoder`, and it was implemented as an internal utility to give it time to mature/evolve and to make the decision to turn it into a public API independent from getting a quick win on JDK-internal code. It seems natural and logical that we keep improving this abstraction rather than manually inline the logic into `URLEncoder`. ------------- PR Comment: https://git.openjdk.org/jdk/pull/16082#issuecomment-1752517839