Streamline code paths

This commit is contained in:
Liam Newman
2021-04-15 15:28:24 -07:00
parent b72e7fa2ee
commit 38f3595552
2 changed files with 8 additions and 11 deletions

View File

@@ -139,7 +139,7 @@ public class GHContentSearchBuilder extends GHSearchBuilder<GHContent> {
*/
public GHContentSearchBuilder sort(GHContentSearchBuilder.Sort sort) {
if (Sort.BEST_MATCH.equals(sort)) {
req.unset("sort");
req.remove("sort");
} else {
req.with("sort", sort);
}

View File

@@ -602,27 +602,24 @@ class GitHubRequest {
* @return the request builder
*/
public B set(String key, Object value) {
for (int index = 0; index < args.size(); index++) {
if (args.get(index).key.equals(key)) {
args.set(index, new Entry(key, value));
return (B) this;
}
}
remove(key);
return with(key, value);
}
/**
* Unset the key field
* Removes all arg entries for a specific key.
*
* @param key
* the key
* @return the request builder
*/
public B unset(String key) {
for (int index = 0; index < args.size(); index++) {
public B remove(String key) {
for (int index = 0; index < args.size();) {
if (args.get(index).key.equals(key)) {
args.remove(index);
break;
} else {
index++;
}
}
return (B) this;