Optimize the SDS string inside the string object to require little space, * in case there is more than 10% of free space at the end of the SDS * string. This happens because SDS strings tend to overallocate to avoid * wasting too much time in allocations when appending to the string. */
| 427 | * string. This happens because SDS strings tend to overallocate to avoid |
| 428 | * wasting too much time in allocations when appending to the string. */ |
| 429 | void trimStringObjectIfNeeded(robj *o) { |
| 430 | if (o->encoding == OBJ_ENCODING_RAW && |
| 431 | sdsavail(o->ptr) > sdslen(o->ptr)/10) |
| 432 | { |
| 433 | o->ptr = sdsRemoveFreeSpace(o->ptr); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | /* Try to encode a string object in order to save space */ |
| 438 | robj *tryObjectEncoding(robj *o) { |
no test coverage detected