MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rdbTryIntegerEncoding

Function rdbTryIntegerEncoding

app/redis-6.2.6/src/rdb.c:319–333  ·  view source on GitHub ↗

String objects in the form "2391" "-100" without any space and with a * range of values that can fit in an 8, 16 or 32 bit signed value can be * encoded as integers to save space */

Source from the content-addressed store, hash-verified

317 * range of values that can fit in an 8, 16 or 32 bit signed value can be
318 * encoded as integers to save space */
319int rdbTryIntegerEncoding(char *s, size_t len, unsigned char *enc) {
320 long long value;
321 char *endptr, buf[32];
322
323 /* Check if it's possible to encode this value as a number */
324 value = strtoll(s, &endptr, 10);
325 if (endptr[0] != '\0') return 0;
326 ll2string(buf,32,value);
327
328 /* If the number converted back into a string is not identical
329 * then it's not possible to encode the string as integer */
330 if (strlen(buf) != len || memcmp(buf,s,len)) return 0;
331
332 return rdbEncodeInteger(value,enc);
333}
334
335ssize_t rdbSaveLzfBlob(rio *rdb, void *data, size_t compress_len,
336 size_t original_len) {

Callers 1

rdbSaveRawStringFunction · 0.85

Calls 2

ll2stringFunction · 0.85
rdbEncodeIntegerFunction · 0.85

Tested by

no test coverage detected