Skip to content

Commit ece093a

Browse files
author
Stephane Landelle
committed
Minor removeQuotes optim
1 parent 8add587 commit ece093a

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

api/src/main/java/org/asynchttpclient/util/AsyncHttpProviderUtils.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import org.asynchttpclient.multipart.MultipartRequestEntity;
4747
import org.asynchttpclient.multipart.PartSource;
4848

49+
import com.ning.http.util.MiscUtil;
50+
4951
/**
5052
* {@link org.asynchttpclient.AsyncHttpProvider} common utilities.
5153
* <p/>
@@ -530,13 +532,24 @@ public static int convertExpireField(String timestring) {
530532
throw new IllegalArgumentException("Not a valid expire field " + trimmedTimeString);
531533
}
532534

533-
private final static String removeQuote(String s) {
535+
public final static String removeQuotes(String s) {
534536
if (MiscUtil.isNonEmpty(s)) {
535-
if (s.charAt(0) == '"')
536-
s = s.substring(1);
537+
int start = 0;
538+
int end = s.length();
539+
boolean changed = false;
540+
541+
if (s.charAt(0) == '"') {
542+
changed = true;
543+
start++;
544+
}
545+
546+
if (s.charAt(s.length() - 1) == '"') {
547+
changed = true;
548+
end--;
549+
}
537550

538-
if (s.charAt(s.length() - 1) == '"')
539-
s = s.substring(0, s.length() - 1);
551+
if (changed)
552+
s = s.substring(start, end);
540553
}
541554
return s;
542555
}

0 commit comments

Comments
 (0)