Skip to content

Commit 2b69a49

Browse files
[Support] Avoid repeated hash lookups (NFC) (#132517)
1 parent 5471810 commit 2b69a49

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/Support/SuffixTree.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ unsigned SuffixTree::extend(unsigned EndIdx, unsigned SuffixesToAdd) {
193193
unsigned FirstChar = Str[Active.Idx];
194194

195195
// Have we inserted anything starting with FirstChar at the current node?
196-
if (Active.Node->Children.count(FirstChar) == 0) {
196+
if (auto It = Active.Node->Children.find(FirstChar);
197+
It == Active.Node->Children.end()) {
197198
// If not, then we can just insert a leaf and move to the next step.
198199
insertLeaf(*Active.Node, EndIdx, FirstChar);
199200

@@ -206,7 +207,7 @@ unsigned SuffixTree::extend(unsigned EndIdx, unsigned SuffixesToAdd) {
206207
} else {
207208
// There's a match with FirstChar, so look for the point in the tree to
208209
// insert a new node.
209-
SuffixTreeNode *NextNode = Active.Node->Children[FirstChar];
210+
SuffixTreeNode *NextNode = It->second;
210211

211212
unsigned SubstringLen = numElementsInSubstring(NextNode);
212213

0 commit comments

Comments
 (0)