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:
Ben Maurer
2013-05-09 15:09:32 -07:00
commit de Sara Golemon
commit e0f8f5bdff
3 arquivos alterados com 19 adições e 16 exclusões
+17
Ver Arquivo
@@ -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);