瀏覽代碼

base: leverage the libc for string comparisons.

legacy
Sam Hocevar sam 11 年之前
父節點
當前提交
9584830bad
共有 1 個文件被更改,包括 9 次插入20 次删除
  1. +9
    -20
      src/lol/base/string.h

+ 9
- 20
src/lol/base/string.h 查看文件

@@ -182,14 +182,9 @@ public:

inline bool operator ==(String const &s) const
{
if (this->m_count != s.m_count)
return false;

for (int i = 0; i < this->m_count; ++i)
if ((*this)[i] != s[i])
return false;

return true;
using namespace std;
return Count() == s.Count()
&& memcmp(C(), s.C(), Count()) == 0;
}

inline bool operator !=(String const &s) const
@@ -197,20 +192,14 @@ public:
return !(*this == s);
}


inline bool operator ==(char const* sz) const
{
int i;
for (i = 0; i < this->m_count; ++i)
{
if (i < this->m_count - 1 && sz[i] == '\0')
return false;

if ((*this)[i] != sz[i])
return false;
}

return true;
/* We parse the C string twice because of strlen + memcmp
* but it's probably still faster than doing it by hand. */
using namespace std;
int sz_len = (int)strlen(sz);
return Count() == sz_len
&& memcmp(C(), sz, sz_len) == 0;
}

inline bool operator !=(char const* sz) const


Loading…
取消
儲存