Use equals() in equals(StringData, StringData)
Equals is faster in a few ways.
(1) no call to memcmp unless string sizes are the same
(2) does a fast check for either of the strings being static
before any calls to is_numeric_string
Esse commit está contido em:
@@ -855,6 +855,23 @@ DataType StringData::toNumeric(int64_t &lval, double &dval) const {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// comparisons
|
||||
|
||||
HOT_FUNC
|
||||
bool StringData::equal(const StringData *s) const {
|
||||
assert(s);
|
||||
if (s == this) return true;
|
||||
int ret;
|
||||
|
||||
if (!(m_hash < 0 || s->m_hash < 0)) {
|
||||
ret = numericCompare(s);
|
||||
if (ret >= -1) {
|
||||
return ret == 0;
|
||||
}
|
||||
}
|
||||
if (m_len != s->m_len) return false;
|
||||
ret = memcmp(rawdata(), s->rawdata(), m_len);
|
||||
return ret == 0;
|
||||
}
|
||||
|
||||
HOT_FUNC
|
||||
int StringData::numericCompare(const StringData *v2) const {
|
||||
assert(v2);
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário