@@ -22,15 +22,18 @@ namespace swift {
22
22
23
23
// Trie node representing a sequence of unsigned integer indices.
24
24
class IndexTrieNode {
25
- static const unsigned RootIdx = ~0U ;
26
- unsigned Index;
25
+ public:
26
+ static const int RootIndex = std::numeric_limits<int >::min();
27
+
28
+ private:
29
+ int Index;
27
30
llvm::SmallVector<IndexTrieNode*, 8 > Children;
28
31
IndexTrieNode *Parent;
29
32
30
33
public:
31
- IndexTrieNode (): Index(RootIdx ), Parent(nullptr ) {}
34
+ IndexTrieNode () : Index(RootIndex ), Parent(nullptr ) {}
32
35
33
- explicit IndexTrieNode (unsigned V, IndexTrieNode *P): Index(V), Parent(P) {}
36
+ explicit IndexTrieNode (int V, IndexTrieNode *P) : Index(V), Parent(P) {}
34
37
35
38
IndexTrieNode (IndexTrieNode &) =delete;
36
39
IndexTrieNode &operator =(const IndexTrieNode&) =delete ;
@@ -40,19 +43,18 @@ class IndexTrieNode {
40
43
delete N;
41
44
}
42
45
43
- bool isRoot () const { return Index == RootIdx ; }
46
+ bool isRoot () const { return Index == RootIndex ; }
44
47
45
48
bool isLeaf () const { return Children.empty (); }
46
49
47
- unsigned getIndex () const { return Index; }
50
+ int getIndex () const { return Index; }
48
51
49
- IndexTrieNode *getChild (unsigned Idx) {
50
- assert (Idx != RootIdx );
52
+ IndexTrieNode *getChild (int Idx) {
53
+ assert (Idx != RootIndex );
51
54
52
- auto I = std::lower_bound (Children.begin (), Children.end (), Idx,
53
- [](IndexTrieNode *a, unsigned i) {
54
- return a->Index < i;
55
- });
55
+ auto I =
56
+ std::lower_bound (Children.begin (), Children.end (), Idx,
57
+ [](IndexTrieNode *a, int i) { return a->Index < i; });
56
58
if (I != Children.end () && (*I)->Index == Idx)
57
59
return *I;
58
60
auto *N = new IndexTrieNode (Idx, this );
0 commit comments