Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Mar 22, 2025

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/132517.diff

1 Files Affected:

  • (modified) llvm/lib/Support/SuffixTree.cpp (+3-2)
diff --git a/llvm/lib/Support/SuffixTree.cpp b/llvm/lib/Support/SuffixTree.cpp
index 5e58310e1128b..5abcead5037f4 100644
--- a/llvm/lib/Support/SuffixTree.cpp
+++ b/llvm/lib/Support/SuffixTree.cpp
@@ -193,7 +193,8 @@ unsigned SuffixTree::extend(unsigned EndIdx, unsigned SuffixesToAdd) {
     unsigned FirstChar = Str[Active.Idx];
 
     // Have we inserted anything starting with FirstChar at the current node?
-    if (Active.Node->Children.count(FirstChar) == 0) {
+    if (auto It = Active.Node->Children.find(FirstChar);
+        It == Active.Node->Children.end()) {
       // If not, then we can just insert a leaf and move to the next step.
       insertLeaf(*Active.Node, EndIdx, FirstChar);
 
@@ -206,7 +207,7 @@ unsigned SuffixTree::extend(unsigned EndIdx, unsigned SuffixesToAdd) {
     } else {
       // There's a match with FirstChar, so look for the point in the tree to
       // insert a new node.
-      SuffixTreeNode *NextNode = Active.Node->Children[FirstChar];
+      SuffixTreeNode *NextNode = It->second;
 
       unsigned SubstringLen = numElementsInSubstring(NextNode);
 

@kazutakahirata kazutakahirata merged commit 2b69a49 into llvm:main Mar 22, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_Suffix branch March 22, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants