Skip to content
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

StringUtils: lazy Pattern evaluation #465

Closed
wants to merge 1 commit into from

Conversation

amarkevich
Copy link
Contributor

return getPattern(regex).splitAsStream(s);
}
static Pattern getPattern(String regex) {
return Optional.ofNullable(PATTERN_MAP.get(regex)).orElseGet(() -> Pattern.compile(regex));
Copy link
Member

@reta reta Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we could use PATTERN_MAP.computeIfAbsent(regex, key -> Pattern.compile(key));?

@amarkevich
Copy link
Contributor Author

I will recheck this method usage; some cases can be switched to String.split fastpath way

@amarkevich amarkevich closed this Oct 24, 2018
amarkevich pushed a commit to amarkevich/cxf that referenced this pull request Dec 5, 2018
amarkevich pushed a commit that referenced this pull request Dec 6, 2018
* String.split via fastpath instead of precompiled Pattern

* Deprecate some StringUtils.split; computeIfAbsent required one (#465)

* finalize; the only place is HttpHeadersImpl due to COOKIE_SEPARATOR_CRLF
@amarkevich amarkevich deleted the string_utils branch December 6, 2018 10:30
rmannibucau pushed a commit to rmannibucau/cxf that referenced this pull request Mar 18, 2019
* String.split via fastpath instead of precompiled Pattern

* Deprecate some StringUtils.split; computeIfAbsent required one (apache#465)

* finalize; the only place is HttpHeadersImpl due to COOKIE_SEPARATOR_CRLF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants