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

Considering improving the PathMatcher #13

Closed
alalag1 opened this issue Dec 14, 2020 · 0 comments · Fixed by #27
Closed

Considering improving the PathMatcher #13

alalag1 opened this issue Dec 14, 2020 · 0 comments · Fixed by #27
Labels
enhancement enhance the existing features
Milestone

Comments

@alalag1
Copy link
Member

alalag1 commented Dec 14, 2020

make the PathMatcher performance up

why

Now, We are using regex to match the path variables of the URI. eg. /foo/{bar}/baz

Maybe we should stop using regex and try to resolve the path variables directly for a nice performance.

boolean matchStrings(String str, Map<String, String> uriTemplateVariables) {
java.util.regex.Matcher matcher = this.pattern.matcher(str);
if (matcher.matches()) {
if (uriTemplateVariables != null) {
// SPR-8455
if (this.variableNames.size() != matcher.groupCount()) {
throw new IllegalArgumentException("The number of capturing groups in the pattern segment " +
this.pattern + " does not match the number of URI template variables it defines, " +
"which can occur if capturing groups are used in a URI template regex. " +
"Use non-capturing groups instead.");
}
for (int i = 1; i <= matcher.groupCount(); i++) {
String name = this.variableNames.get(i - 1);
String value = matcher.group(i);
uriTemplateVariables.put(name, value);
}
}
return true;
} else {
return false;
}
}

@alalag1 alalag1 added the enhancement enhance the existing features label Dec 14, 2020
@alalag1 alalag1 added this to the v0.1.1 milestone Dec 30, 2020
@alalag1 alalag1 linked a pull request Dec 30, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement enhance the existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant