Skip to content

Commit f4082e0

Browse files
committed
Translate EMPTY_TRIE to empty builder, and persisted empty builder to EMPTY_TRIE
1 parent e0381c8 commit f4082e0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

utils/src/main/java/datadog/instrument/utils/ClassNameTrie.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ public static ClassNameTrie readFrom(DataInput in) throws IOException {
251251
throw new IOException("Unexpected file magic " + magic);
252252
}
253253
int trieLength = in.readInt();
254+
if (trieLength == 0) {
255+
return EMPTY_TRIE;
256+
}
254257
char[] trieData = new char[trieLength];
255258
for (int i = 0; i < trieLength; i++) {
256259
byte b = in.readByte();
@@ -309,10 +312,12 @@ public Builder() {}
309312
* @param trie existing trie
310313
*/
311314
public Builder(ClassNameTrie trie) {
312-
trieData = trie.trieData;
313-
trieLength = trieData.length;
314-
longJumps = trie.longJumps;
315-
longJumpCount = null != longJumps ? longJumps.length : 0;
315+
if (trie.trieData.length > 1) { // non-empty trie (branch count + content)
316+
trieData = trie.trieData;
317+
trieLength = trieData.length;
318+
longJumps = trie.longJumps;
319+
longJumpCount = null != longJumps ? longJumps.length : 0;
320+
}
316321
}
317322

318323
/**

0 commit comments

Comments
 (0)