Skip to content

Commit c3371a6

Browse files
authored
[ADT][NFC] Style and nit fixes in SmallSet (#108582)
1 parent 2f50b28 commit c3371a6

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

llvm/include/llvm/ADT/SmallSet.h

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,33 @@ class SmallSetIterator
4646
VecIterTy VecIter;
4747
};
4848

49-
bool isSmall;
49+
bool IsSmall;
5050

5151
public:
52-
SmallSetIterator(SetIterTy SetIter) : SetIter(SetIter), isSmall(false) {}
52+
SmallSetIterator(SetIterTy SetIter) : SetIter(SetIter), IsSmall(false) {}
5353

54-
SmallSetIterator(VecIterTy VecIter) : VecIter(VecIter), isSmall(true) {}
54+
SmallSetIterator(VecIterTy VecIter) : VecIter(VecIter), IsSmall(true) {}
5555

5656
// Spell out destructor, copy/move constructor and assignment operators for
5757
// MSVC STL, where set<T>::const_iterator is not trivially copy constructible.
5858
~SmallSetIterator() {
59-
if (isSmall)
59+
if (IsSmall)
6060
VecIter.~VecIterTy();
6161
else
6262
SetIter.~SetIterTy();
6363
}
6464

65-
SmallSetIterator(const SmallSetIterator &Other) : isSmall(Other.isSmall) {
66-
if (isSmall)
65+
SmallSetIterator(const SmallSetIterator &Other) : IsSmall(Other.IsSmall) {
66+
if (IsSmall)
6767
VecIter = Other.VecIter;
6868
else
6969
// Use placement new, to make sure SetIter is properly constructed, even
7070
// if it is not trivially copy-able (e.g. in MSVC).
7171
new (&SetIter) SetIterTy(Other.SetIter);
7272
}
7373

74-
SmallSetIterator(SmallSetIterator &&Other) : isSmall(Other.isSmall) {
75-
if (isSmall)
74+
SmallSetIterator(SmallSetIterator &&Other) : IsSmall(Other.IsSmall) {
75+
if (IsSmall)
7676
VecIter = std::move(Other.VecIter);
7777
else
7878
// Use placement new, to make sure SetIter is properly constructed, even
@@ -83,11 +83,11 @@ class SmallSetIterator
8383
SmallSetIterator& operator=(const SmallSetIterator& Other) {
8484
// Call destructor for SetIter, so it gets properly destroyed if it is
8585
// not trivially destructible in case we are setting VecIter.
86-
if (!isSmall)
86+
if (!IsSmall)
8787
SetIter.~SetIterTy();
8888

89-
isSmall = Other.isSmall;
90-
if (isSmall)
89+
IsSmall = Other.IsSmall;
90+
if (IsSmall)
9191
VecIter = Other.VecIter;
9292
else
9393
new (&SetIter) SetIterTy(Other.SetIter);
@@ -97,34 +97,34 @@ class SmallSetIterator
9797
SmallSetIterator& operator=(SmallSetIterator&& Other) {
9898
// Call destructor for SetIter, so it gets properly destroyed if it is
9999
// not trivially destructible in case we are setting VecIter.
100-
if (!isSmall)
100+
if (!IsSmall)
101101
SetIter.~SetIterTy();
102102

103-
isSmall = Other.isSmall;
104-
if (isSmall)
103+
IsSmall = Other.IsSmall;
104+
if (IsSmall)
105105
VecIter = std::move(Other.VecIter);
106106
else
107107
new (&SetIter) SetIterTy(std::move(Other.SetIter));
108108
return *this;
109109
}
110110

111111
bool operator==(const SmallSetIterator &RHS) const {
112-
if (isSmall != RHS.isSmall)
112+
if (IsSmall != RHS.IsSmall)
113113
return false;
114-
if (isSmall)
114+
if (IsSmall)
115115
return VecIter == RHS.VecIter;
116116
return SetIter == RHS.SetIter;
117117
}
118118

119119
SmallSetIterator &operator++() { // Preincrement
120-
if (isSmall)
121-
VecIter++;
120+
if (IsSmall)
121+
++VecIter;
122122
else
123-
SetIter++;
123+
++SetIter;
124124
return *this;
125125
}
126126

127-
const T &operator*() const { return isSmall ? *VecIter : *SetIter; }
127+
const T &operator*() const { return IsSmall ? *VecIter : *SetIter; }
128128
};
129129

130130
/// SmallSet - This maintains a set of unique values, optimizing for the case
@@ -167,9 +167,8 @@ class SmallSet {
167167
if (isSmall()) {
168168
// Since the collection is small, just do a linear search.
169169
return vfind(V) == Vector.end() ? 0 : 1;
170-
} else {
171-
return Set.count(V);
172170
}
171+
return Set.count(V);
173172
}
174173

175174
/// insert - Insert an element into the set if it isn't already there.

0 commit comments

Comments
 (0)