-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Micro optimisation: calls to String.replaceAll need to be replaced #1608
Comments
01es
added a commit
that referenced
this issue
Oct 26, 2020
…nchmark and two sets of benchmark tests.
01es
added a commit
that referenced
this issue
Oct 27, 2020
…cement with empty string, using various ways.
01es
added a commit
that referenced
this issue
Oct 27, 2020
…chmark methods -- benchmark classes (even patterns) can be specified as command line arguments.
01es
added a commit
that referenced
this issue
Oct 27, 2020
01es
added a commit
that referenced
this issue
Oct 27, 2020
…ils.remove' and 'RegExUtils.removeAll'.
01es
added a commit
that referenced
this issue
Oct 27, 2020
01es
added a commit
that referenced
this issue
Oct 27, 2020
01es
added a commit
that referenced
this issue
Oct 28, 2020
Merged
01es
added a commit
that referenced
this issue
Oct 28, 2020
01es
added a commit
that referenced
this issue
Oct 28, 2020
jhou-pro
added a commit
that referenced
this issue
Oct 28, 2020
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
…nchmark and two sets of benchmark tests.
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
…cement with empty string, using various ways.
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
…chmark methods -- benchmark classes (even patterns) can be specified as command line arguments.
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
…ils.remove' and 'RegExUtils.removeAll'.
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
…ty methods that are not longer used.
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
oleh-maikovych
pushed a commit
that referenced
this issue
Nov 2, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
String.replaceAll
is implemented using regular expression with a pattern compiled upon each call. Matching even short strings is computationally expensive. In TG we have multiple places whereString.replaceAll
is used extensively and some places where it is used accidentally, andString.replace
would suffice.Performance of
String.replace
is much better as it does not support regular expression. However, under Java8 it still performs worse than alternativeStringUtils.replace()
from Apache Commons Lang, which has optimisation for strings with no matches. Starting with Java9, the performance forString.replace
is equivalent toStringUtils.replace()
.Therefore, the main objective of this issue is to inspect all calls to
String.replaceAll
and improve them.Replace calls to
String.replaceAll
toString.replace
where no regular expression matching is necessary, and withStringUtils.remove
where replacement is with an empty string.Replace calls to
String.replaceAll
where regular expression is needed by using a precompiled pattern where possible.RegExUtils
could be conveniently used for this purpose.- [ ] Consider replacing--String.split
with Guava Splitter for optimal performance.String.split
turned out to be more efficient.Expected outcome
Improved performance.
The text was updated successfully, but these errors were encountered: