Commit 2ad6f133 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1576 Remove 'return a-b' comparison trick from default key compare function

git-svn-id: file:///svn/toku/tokudb@10394 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9f2d99f2
...@@ -60,7 +60,9 @@ int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2le ...@@ -60,7 +60,9 @@ int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2le
return (int)*k1-(int)*k2; return (int)*k1-(int)*k2;
} }
} }
return key1len-key2len; if (key1len<key2len) return -1;
if (key1len>key2len) return 1;
return 0;
} }
#else #else
/* unroll that one four times */ /* unroll that one four times */
...@@ -84,8 +86,9 @@ int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2le ...@@ -84,8 +86,9 @@ int toku_keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2le
return (int)*k1-(int)*k2; return (int)*k1-(int)*k2;
} }
} }
//See #1576. For very large keylengths this is a problem. Our maximum keysize is << INT_MAX so this is not an issue. if (key1len<key2len) return -1;
return key1len-key2len; if (key1len>key2len) return 1;
return 0;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment