oblac / jodd-util

Essential Java utilities.
https://util.jodd.org
BSD 2-Clause "Simplified" License
39 stars 9 forks source link

StringUtil#remove(char): copy chars by chunk instead of one by one #3

Closed slandelle closed 3 years ago

slandelle commented 3 years ago

Motivation:

Chars are currently copied one by one in the StringBuilder.

Modification:

Use String#indexOf to locate char position and then StringBuilder#append(string, start, end) to copy chars by chunk.

Result:

Better performance.

slandelle commented 3 years ago

WARNING: performance gain to be verified on small Strings, which is the typical usage in Lagarto's CssSelector#unescape.

codecov[bot] commented 3 years ago

Codecov Report

Merging #3 into string-builder-pool will increase coverage by 0.03%. The diff coverage is 100.00%.

Impacted file tree graph

@@                    Coverage Diff                    @@
##             string-builder-pool       #3      +/-   ##
=========================================================
+ Coverage                  74.12%   74.15%   +0.03%     
+ Complexity                  2887     2886       -1     
=========================================================
  Files                        123      123              
  Lines                       9194     9197       +3     
  Branches                    1919     1919              
=========================================================
+ Hits                        6815     6820       +5     
+ Misses                      1882     1881       -1     
+ Partials                     497      496       -1     
Impacted Files Coverage Δ Complexity Δ
src/main/java/jodd/util/StringUtil.java 96.14% <100.00%> (+0.18%) 517.00 <4.00> (-1.00) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7865127...ad2fddd. Read the comment docs.