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. */
| 465 | * string. This happens because SDS strings tend to overallocate to avoid |
| 466 | * wasting too much time in allocations when appending to the string. */ |
| 467 | void trimStringObjectIfNeeded(robj *o) { |
| 468 | if (o->encoding == OBJ_ENCODING_RAW && |
| 469 | sdsavail(szFromObj(o)) > sdslen(szFromObj(o))/10) |
| 470 | { |
| 471 | o->m_ptr = sdsRemoveFreeSpace(szFromObj(o)); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | /* Try to encode a string object in order to save space */ |
| 476 | robj *tryObjectEncoding(robj *o) { |
no test coverage detected