You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/08/01 04:31:24 UTC
[Bug 56801] New: Avoid duplicated String to CharArray conversion in
the loop of Matcher#matchName
https://issues.apache.org/bugzilla/show_bug.cgi?id=56801
Bug ID: 56801
Summary: Avoid duplicated String to CharArray conversion in the
loop of Matcher#matchName
Product: Tomcat 7
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: dev@tomcat.apache.org
Reporter: xshao@ebay.com
Created attachment 31865
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31865&action=edit
Patch for Matcher
The loop in matchName,
public static boolean matchName(Set<String> patternSet, String fileName) {
for (String pattern: patternSet) {
if (match(pattern, fileName, true)) {
return true;
}
}
return false;
}
Optimized,
public static boolean matchName(Set<String> patternSet, String fileName) {
char[] charArray = fileName.toCharArray();
for (String pattern: patternSet) {
if (match(pattern, charArray, true)) {
return true;
}
}
return false;
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 56801] Avoid duplicated String to CharArray conversion in the
loop of Matcher#matchName
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56801
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from Mark Thomas <ma...@apache.org> ---
Based on the quality of patches the OP has provided in the past, I'm confident
that a) the proposed change will be faster and b) there is unlikely to be a
better way.
I've applied a variation of this patch to 8.0.x for 8.0.11 onwards.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 56801] Avoid duplicated String to CharArray conversion in the
loop of Matcher#matchName
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56801
Sheldon Shao <xs...@ebay.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31865|0 |1
is patch| |
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 56801] Avoid duplicated String to CharArray conversion in the
loop of Matcher#matchName
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56801
--- Comment #1 from Christopher Schultz <ch...@christopherschultz.net> ---
I think the real question is whether or not the String.toCharArray even belongs
here. Back in the dark days, only fools used String.charAt and instead used
String.toCharArray followed by direct index access. I haven't done any
performance measurements, but String.toCharArray may be more trouble than it's
worth these days.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 56801] Avoid duplicated String to CharArray conversion in the
loop of Matcher#matchName
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56801
--- Comment #3 from Konstantin Kolinko <kn...@gmail.com> ---
(In reply to Christopher Schultz from comment #1)
> I think the real question is whether or not the String.toCharArray even
> belongs here.
Agreed. I changed visibility of the new method to be private, so that we were
able to review the API later. There is also a question that patterns are also
repeatedly converted to arrays.
I backported this to Tomcat 7 in r1617475 and it will be in 7.0.56 onwards.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org