Changeset 2763 for trunk/src/lol/base/string.h
- Timestamp:
- Jun 22, 2013, 5:32:09 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lol/base/string.h
r2759 r2763 183 183 inline bool operator ==(String const &s) const 184 184 { 185 if (this->m_count != s.m_count) 186 return false; 187 188 for (int i = 0; i < this->m_count; ++i) 189 if ((*this)[i] != s[i]) 190 return false; 191 192 return true; 185 using namespace std; 186 return Count() == s.Count() 187 && memcmp(C(), s.C(), Count()) == 0; 193 188 } 194 189 … … 198 193 } 199 194 200 201 195 inline bool operator ==(char const* sz) const 202 196 { 203 int i; 204 for (i = 0; i < this->m_count; ++i) 205 { 206 if (i < this->m_count - 1 && sz[i] == '\0') 207 return false; 208 209 if ((*this)[i] != sz[i]) 210 return false; 211 } 212 213 return true; 197 /* We parse the C string twice because of strlen + memcmp 198 * but it's probably still faster than doing it by hand. */ 199 using namespace std; 200 int sz_len = (int)strlen(sz); 201 return Count() == sz_len 202 && memcmp(C(), sz, sz_len) == 0; 214 203 } 215 204
Note: See TracChangeset
for help on using the changeset viewer.