GitHub user sjcorbett opened a pull request:
https://github.com/apache/incubator-brooklyn/pull/641
brooklyn.util.text.Strings adjustments
Prompted by the chance observation in VisualVM that way too much CPU time
was spent in `Strings.removeFromStart/End ` via
`Exceptions.stripBoringPrefixes` and `PropagatedRuntimeException`. Please check
a with careful eye.
For more on the time complexity of `String.substring` see
http://stackoverflow.com/questions/4679746/time-complexity-of-javas-substring
and
http://stackoverflow.com/questions/16123446/java-7-string-substring-complexity.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/sjcorbett/incubator-brooklyn strings
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-brooklyn/pull/641.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #641
----
commit 3b4aca2119839b4a29872f7c8db71d69ad863451
Author: Sam Corbett <[email protected]>
Date: 2015-05-12T18:16:32Z
assert(actual, expected) in StringsTest
commit 5f7e5f99e7aea8363db3295cdabe94548b6d456e
Author: Sam Corbett <[email protected]>
Date: 2015-05-12T19:21:11Z
Deprecates removeFromStart/End(String, String...)
The only uses of Start that give more than one prefix are the method's
tests. There is only one use of End that may as well be removeAllFromEnd.
commit 1de76aa7998d008eb0c8b9c54a0cb6b556795389
Author: Sam Corbett <[email protected]>
Date: 2015-05-12T19:26:57Z
Strings.removeAllFromStart/End only call substring() once.
Java 7 update 6 changed the cost of String.substring from O(1) to O(n).
This commit changes the two removeAll methods to make one substring calls
rather than one per match.
commit 625e8ac5c395f6ee64d43324223bf64f1ab55275
Author: Sam Corbett <[email protected]>
Date: 2015-05-12T19:28:48Z
Exceptions.stripBoringPrefixes calls removeAllFromStart once with all
prefixes
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---