ofbiz-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacques Le Roux (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (OFBIZ-10934) Performance Increase: Using replace() instead of replaceAll() when a regex is not used increases performance
Date Tue, 23 Apr 2019 08:35:00 GMT

    [ https://issues.apache.org/jira/browse/OFBIZ-10934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16823820#comment-16823820
] 

Jacques Le Roux edited comment on OFBIZ-10934 at 4/23/19 8:34 AM:
------------------------------------------------------------------

You are welcome, now about performance I think we can all agree on the answer about performance
at https://stackoverflow.com/questions/10827872/difference-between-string-replace-and-replaceall:

bq. Now as far as the performance is concerned, the replace() method is a bit faster than
replaceAll() because the latter first compiles the regex pattern and then matches before finally
replacing whereas the former simply matches for the provided argument and replaces. Since
we know the regex pattern matching is a bit more complex and consequently slower, then preferring
replace() over replaceAll() is suggested whenever possible.

There are 87 occurences of replaceAll() in Java, Groovy and Gradle code. Some are {{java.util.regex.Matcher}}
and should not be changed. Some are using regexp and should not be changed too. Now if you
want these to be applied please provide a complete patch. Else I don't see what we are trying
to achieve here. Except in maybe some specific cases where it would make a big difference,
like when iterating, etc.

Else I'll close as incomplete, sorry we have bigger fishes to fry...


was (Author: jacques.le.roux):
You are welcome, now about performance I think we can all agree on the answer about performance
at https://stackoverflow.com/questions/10827872/difference-between-string-replace-and-replaceall:

bq. Now as far as the performance is concerned, the replace() method is a bit faster than
replaceAll() because the latter first compiles the regex pattern and then matches before finally
replacing whereas the former simply matches for the provided argument and replaces. Since
we know the regex pattern matching is a bit more complex and consequently slower, then preferring
replace() over replaceAll() is suggested whenever possible.

There are 87 occurences of replaceAll() in Java, Groovy and Gradle code. Some are {{java.util.regex.Matcher}}
and should not be changed. Some are using regexp and should not be changed too. Now if you
want these to be applied please provide a complete patch. Else I don't see what we are trying
to achieve here. Except in maybe some specific cases where it would make a big difference,
like when iterating, etc.

> Performance Increase: Using replace() instead of replaceAll() when a regex is not used
increases performance
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: OFBIZ-10934
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10934
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: bd2019us
>            Priority: Trivial
>              Labels: pull-request-available
>         Attachments: OFBIZ-10934.patch
>
>
> Affected files:
> # framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
> # framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
> # framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java
> # framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java 
> When replaceAll() is utilized and no regex is used, replaceAll() can be replaced with
replace() for better performance.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message