1
0
mirror of synced 2026-04-25 03:04:45 +08:00

调整 map 声明时的初始容量

This commit is contained in:
yadong.zhang
2021-03-29 10:44:28 +08:00
parent 6a479d9c1d
commit 13514d6a92
9 changed files with 24 additions and 21 deletions

View File

@@ -101,15 +101,18 @@ public class GlobalAuthUtils {
* @return map
*/
public static Map<String, String> parseStringToMap(String accessTokenStr) {
Map<String, String> res = new HashMap<>(6);
Map<String, String> res = null;
if (accessTokenStr.contains("&")) {
String[] fields = accessTokenStr.split("&");
res = new HashMap<>((int) (fields.length / 0.75 + 1));
for (String field : fields) {
if (field.contains("=")) {
String[] keyValue = field.split("=");
res.put(GlobalAuthUtils.urlDecode(keyValue[0]), keyValue.length == 2 ? GlobalAuthUtils.urlDecode(keyValue[1]) : null);
}
}
} else {
res = new HashMap<>(0);
}
return res;
}