MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / rdbTryIntegerEncoding

Function rdbTryIntegerEncoding

src/rdb.cpp:324–338  ·  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

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

Callers 1

rdbSaveRawStringFunction · 0.85

Calls 2

ll2stringFunction · 0.85
rdbEncodeIntegerFunction · 0.85

Tested by

no test coverage detected