Unverified Commit 1bab4cd1 authored by DarrenJiang13's avatar DarrenJiang13 Committed by GitHub
Browse files

try a more concise rdbTryIntegerEncoding using string2ll rather than strtoll. (#8926)

when string2ll was made to replace isStringRepresentableAsLongLong
(which was similar to what rdbTryIntegerEncoding does),
rdbTryIntegerEncoding was probably forgotten.
parent 09a99fcd
...@@ -318,18 +318,11 @@ void *rdbLoadIntegerObject(rio *rdb, int enctype, int flags, size_t *lenptr) { ...@@ -318,18 +318,11 @@ void *rdbLoadIntegerObject(rio *rdb, int enctype, int flags, size_t *lenptr) {
* encoded as integers to save space */ * encoded as integers to save space */
int rdbTryIntegerEncoding(char *s, size_t len, unsigned char *enc) { int rdbTryIntegerEncoding(char *s, size_t len, unsigned char *enc) {
long long value; long long value;
char *endptr, buf[32]; if (string2ll(s, len, &value)) {
return rdbEncodeInteger(value, enc);
/* Check if it's possible to encode this value as a number */ } else {
value = strtoll(s, &endptr, 10); return 0;
if (endptr[0] != '\0') return 0; }
ll2string(buf,32,value);
/* If the number converted back into a string is not identical
* then it's not possible to encode the string as integer */
if (strlen(buf) != len || memcmp(buf,s,len)) return 0;
return rdbEncodeInteger(value,enc);
} }
ssize_t rdbSaveLzfBlob(rio *rdb, void *data, size_t compress_len, ssize_t rdbSaveLzfBlob(rio *rdb, void *data, size_t compress_len,
......
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