Skip to content

Commit

Permalink
MINOR: Remove Dead Code from PathTrie (elastic#33280)
Browse files Browse the repository at this point in the history
* The array size checks are redundant since the array sizes
are checked earlier in those methods too
* The removed methods are just not used anywhere
  • Loading branch information
original-brownbear committed Aug 31, 2018
1 parent f3b848a commit 4e8d37d
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions server/src/main/java/org/elasticsearch/common/path/PathTrie.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,12 @@ public void updateKeyWithNamedWildcard(String key) {
namedWildcard = key.substring(key.indexOf('{') + 1, key.indexOf('}'));
}

public boolean isWildcard() {
return isWildcard;
}

public synchronized void addChild(TrieNode child) {
addInnerChild(child.key, child);
}

private void addInnerChild(String key, TrieNode child) {
Map<String, TrieNode> newChildren = new HashMap<>(children);
newChildren.put(key, child);
children = unmodifiableMap(newChildren);
}

public TrieNode getChild(String key) {
return children.get(key);
}

public synchronized void insert(String[] path, int index, T value) {
if (index >= path.length)
return;
Expand Down Expand Up @@ -302,7 +290,7 @@ public void insert(String path, T value) {
}
int index = 0;
// Supports initial delimiter.
if (strings.length > 0 && strings[0].isEmpty()) {
if (strings[0].isEmpty()) {
index = 1;
}
root.insert(strings, index, value);
Expand All @@ -327,7 +315,7 @@ public void insertOrUpdate(String path, T value, BiFunction<T, T, T> updater) {
}
int index = 0;
// Supports initial delimiter.
if (strings.length > 0 && strings[0].isEmpty()) {
if (strings[0].isEmpty()) {
index = 1;
}
root.insertOrUpdate(strings, index, value, updater);
Expand All @@ -352,7 +340,7 @@ public T retrieve(String path, Map<String, String> params, TrieMatchingMode trie
int index = 0;

// Supports initial delimiter.
if (strings.length > 0 && strings[0].isEmpty()) {
if (strings[0].isEmpty()) {
index = 1;
}

Expand Down

0 comments on commit 4e8d37d

Please sign in to comment.