Skip to content

Commit b6b1ea6

Browse files
author
Stephane Landelle
committed
removeQuotes minor optim
1 parent 82f6c2b commit b6b1ea6

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public static Cookie parseCookie(String value) {
498498
}
499499

500500
public static int convertExpireField(String timestring) {
501-
String trimmedTimeString = removeQuote(timestring.trim());
501+
String trimmedTimeString = removeQuotes(timestring.trim());
502502
long now = System.currentTimeMillis();
503503
Date date = null;
504504

@@ -515,13 +515,24 @@ public static int convertExpireField(String timestring) {
515515
throw new IllegalArgumentException("Not a valid expire field " + trimmedTimeString);
516516
}
517517

518-
private final static String removeQuote(String s) {
518+
public final static String removeQuotes(String s) {
519519
if (MiscUtil.isNonEmpty(s)) {
520-
if (s.charAt(0) == '"')
521-
s = s.substring(1);
520+
int start = 0;
521+
int end = s.length();
522+
boolean changed = false;
522523

523-
if (s.charAt(s.length() - 1) == '"')
524-
s = s.substring(0, s.length() - 1);
524+
if (s.charAt(0) == '"') {
525+
changed = true;
526+
start++;
527+
}
528+
529+
if (s.charAt(s.length() - 1) == '"') {
530+
changed = true;
531+
end--;
532+
}
533+
534+
if (changed)
535+
s = s.substring(start, end);
525536
}
526537
return s;
527538
}

0 commit comments

Comments
 (0)