Skip to content

Commit c168c03

Browse files
MINOR: Remove Dead Code from PathTrie (#33280) (#33306)
* 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
1 parent fdc5817 commit c168c03

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

server/src/main/java/org/elasticsearch/common/path/PathTrie.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,12 @@ public void updateKeyWithNamedWildcard(String key) {
104104
namedWildcard = key.substring(key.indexOf('{') + 1, key.indexOf('}'));
105105
}
106106

107-
public boolean isWildcard() {
108-
return isWildcard;
109-
}
110-
111-
public synchronized void addChild(TrieNode child) {
112-
addInnerChild(child.key, child);
113-
}
114-
115107
private void addInnerChild(String key, TrieNode child) {
116108
Map<String, TrieNode> newChildren = new HashMap<>(children);
117109
newChildren.put(key, child);
118110
children = unmodifiableMap(newChildren);
119111
}
120112

121-
public TrieNode getChild(String key) {
122-
return children.get(key);
123-
}
124-
125113
public synchronized void insert(String[] path, int index, T value) {
126114
if (index >= path.length)
127115
return;
@@ -302,7 +290,7 @@ public void insert(String path, T value) {
302290
}
303291
int index = 0;
304292
// Supports initial delimiter.
305-
if (strings.length > 0 && strings[0].isEmpty()) {
293+
if (strings[0].isEmpty()) {
306294
index = 1;
307295
}
308296
root.insert(strings, index, value);
@@ -327,7 +315,7 @@ public void insertOrUpdate(String path, T value, BiFunction<T, T, T> updater) {
327315
}
328316
int index = 0;
329317
// Supports initial delimiter.
330-
if (strings.length > 0 && strings[0].isEmpty()) {
318+
if (strings[0].isEmpty()) {
331319
index = 1;
332320
}
333321
root.insertOrUpdate(strings, index, value, updater);
@@ -352,7 +340,7 @@ public T retrieve(String path, Map<String, String> params, TrieMatchingMode trie
352340
int index = 0;
353341

354342
// Supports initial delimiter.
355-
if (strings.length > 0 && strings[0].isEmpty()) {
343+
if (strings[0].isEmpty()) {
356344
index = 1;
357345
}
358346

0 commit comments

Comments
 (0)