Skip to content

Commit 5c10a83

Browse files
committed
Merge branch 'feature/refactor_string' of https://github.com/kimkulling/cppcore into feature/refactor_string
2 parents 5c5dbf5 + 76bd06a commit 5c10a83

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/cppcore/Common/TStringBase.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ inline void TStringBase<T>::clear() {
158158
mStringBuffer = nullptr;
159159
mCapacity = InitSize;
160160
}
161-
mSize = 0;
161+
reset();
162162
}
163163

164164
template <class T>
@@ -184,8 +184,12 @@ inline bool TStringBase<T>::operator == (const TStringBase<T> &rhs) const {
184184
return false;
185185
}
186186

187+
if (mHashId != rhs.mHashId) {
188+
return false;
189+
}
187190

188-
return mHashId == rhs.mHashId;
191+
// Fallback to actual comparison in case of hash collision
192+
return memcmp(c_str(), rhs.c_str(), mSize * sizeof(T)) == 0;
189193
}
190194

191195
template <class T>

0 commit comments

Comments
 (0)