Skip to content

Commit

Permalink
Minor performance improvements when parsing query params
Browse files Browse the repository at this point in the history
  • Loading branch information
jentfoo committed May 8, 2018
1 parent f688376 commit 1a79dc6
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ public static Map<String, List<String>> queryToMap(String query) {
Map<String, List<String>> map = new HashMap<>();
if(query.startsWith("?")) {
query = query.substring(1);
} else if (query.contains("?")){
int qpos = query.indexOf("?");
}
int qpos = query.indexOf("?");
if (qpos >= 0){
query = query.substring(qpos+1);
}
String[] tmpQ = query.trim().split("&");
Expand All @@ -100,7 +101,7 @@ public static Map<String, List<String>> queryToMap(String query) {
// case where either no `=` or empty key string
continue;
}
List<String> paramValues = map.computeIfAbsent(tmpkv[0], (ignored) -> new ArrayList<>(1));
List<String> paramValues = map.computeIfAbsent(tmpkv[0], (ignored) -> new ArrayList<>(2));
if(tmpkv.length == 1) {
paramValues.add("");
} else {
Expand Down

0 comments on commit 1a79dc6

Please sign in to comment.