Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize URL#addParameters method to reuse existing methods #8005

Merged
merged 2 commits into from Jun 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 2 additions & 10 deletions dubbo-common/src/main/java/org/apache/dubbo/common/URL.java
Expand Up @@ -1244,18 +1244,10 @@ public URL addParametersIfAbsent(Map<String, String> parameters) {
}

public URL addParameters(String... pairs) {
if (pairs == null || pairs.length == 0) {
if (ArrayUtils.isEmpty(pairs)) {
return this;
}
if (pairs.length % 2 != 0) {
throw new IllegalArgumentException("Map pairs can not be odd number.");
}
Map<String, String> map = new HashMap<>();
int len = pairs.length / 2;
for (int i = 0; i < len; i++) {
map.put(pairs[2 * i], pairs[2 * i + 1]);
}
return addParameters(map);
return addParameters(CollectionUtils.toStringMap(pairs));
}

public URL addParameterString(String query) {
Expand Down