Fix inefficient loop in QueryStringDecoder.decodeComponent()

- Fixes #2228
- There's no point of looping until the end of the component if at least one '%' or '+' is found.
This commit is contained in:
Trustin Lee 2014-02-14 13:25:57 -08:00
parent 6c02e19d10
commit c73e1e3c1e

View File

@ -311,13 +311,9 @@ public class QueryStringDecoder {
boolean modified = false;
for (int i = 0; i < size; i++) {
final char c = s.charAt(i);
switch (c) {
case '%':
i++; // We can skip at least one char, e.g. `%%'.
// Fall through.
case '+':
modified = true;
break;
if (c == '%' || c == '+') {
modified = true;
break;
}
}
if (!modified) {