Skip to content

Commit 2764d84

Browse files
committed
Fix static check findings
1 parent 8c0fcd0 commit 2764d84

File tree

2 files changed

+12
-34
lines changed

2 files changed

+12
-34
lines changed

include/cppcore/Container/TArray.h

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,37 +181,25 @@ class TArray {
181181

182182
private:
183183
TAlloc mAllocator;
184-
size_t mSize;
185-
size_t mCapacity;
186-
T *mData;
184+
size_t mSize = 0u;
185+
size_t mCapacity = 0u;
186+
T *mData = nullptr;
187187
};
188188

189189
template <class T, class TAlloc>
190-
inline TArray<T, TAlloc>::TArray() :
191-
mAllocator(),
192-
mSize(0u),
193-
mCapacity(0u),
194-
mData(nullptr) {
190+
inline TArray<T, TAlloc>::TArray() {
195191
// empty
196192
}
197193

198194
template <class T, class TAlloc>
199-
inline TArray<T, TAlloc>::TArray(size_t size) :
200-
mAllocator(),
201-
mSize(0u),
202-
mCapacity(0u),
203-
mData(nullptr) {
195+
inline TArray<T, TAlloc>::TArray(size_t size) {
204196
const size_t capa = Details::getGrowing(size);
205197
reserve(capa);
206198
resize(size);
207199
}
208200

209201
template <class T, class TAlloc>
210-
inline TArray<T, TAlloc>::TArray(const TArray<T, TAlloc> &rhs) :
211-
mAllocator(),
212-
mSize(0u),
213-
mCapacity(0u),
214-
mData(nullptr) {
202+
inline TArray<T, TAlloc>::TArray(const TArray<T, TAlloc> &rhs) {
215203
resize(rhs.mSize);
216204
for (size_t i = 0u; i < mSize; ++i) {
217205
mData[i] = rhs.mData[i];

include/cppcore/Container/THashMap.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class THashMap {
5555
/// @brief Marker for unset node keys.
5656
static constexpr unsigned int UnsetNode = 999999999;
5757

58-
public:
5958
/// @brief The class constructor.
6059
/// @param init [in] The initial size for the hash.
6160
explicit THashMap(size_t init = InitSize);
@@ -114,27 +113,24 @@ class THashMap {
114113

115114
private:
116115
struct Node {
117-
T mKey;
116+
T mKey = UnsetNode;
118117
U mValue;
119118
Node *mNext;
120119

121120
Node();
122-
~Node();
121+
~Node() = default;
123122
void append(T key, const U &value);
124123
bool remove(T key);
125124
void releaseList();
126125
};
127126

128-
Node **mBuffer;
129-
size_t mNumItems;
130-
size_t mBuffersize;
127+
Node **mBuffer = nullptr;
128+
size_t mNumItems = 0u;
129+
size_t mBuffersize = 0u;
131130
};
132131

133132
template <class T, class U, class TAlloc>
134-
inline THashMap<T, U, TAlloc>::THashMap(size_t initSize) :
135-
mBuffer(nullptr),
136-
mNumItems(0u),
137-
mBuffersize(0u) {
133+
inline THashMap<T, U, TAlloc>::THashMap(size_t initSize) {
138134
init(initSize);
139135
}
140136

@@ -291,17 +287,11 @@ inline U &THashMap<T, U, TAlloc>::operator[](const T &key) const {
291287

292288
template <class T, class U, class TAlloc>
293289
inline THashMap<T, U, TAlloc>::Node::Node() :
294-
mKey(UnsetNode),
295290
mValue(),
296291
mNext(nullptr) {
297292
// empty
298293
}
299294

300-
template <class T, class U, class TAlloc>
301-
inline THashMap<T, U, TAlloc>::Node::~Node() {
302-
mNext = nullptr;
303-
}
304-
305295
template <class T, class U, class TAlloc>
306296
inline void THashMap<T, U, TAlloc>::Node::append(T key, const U &value) {
307297
if (mKey == UnsetNode) {

0 commit comments

Comments
 (0)