Get a decoded version of an encoded object (returned as a new object). * If the object is already raw-encoded just increment the ref count. */
| 555 | /* Get a decoded version of an encoded object (returned as a new object). |
| 556 | * If the object is already raw-encoded just increment the ref count. */ |
| 557 | robj *getDecodedObject(robj *o) { |
| 558 | robj *dec; |
| 559 | |
| 560 | if (sdsEncodedObject(o)) { |
| 561 | incrRefCount(o); |
| 562 | return o; |
| 563 | } |
| 564 | if (o->type == OBJ_STRING && o->encoding == OBJ_ENCODING_INT) { |
| 565 | char buf[32]; |
| 566 | |
| 567 | ll2string(buf,32,(long)ptrFromObj(o)); |
| 568 | dec = createStringObject(buf,strlen(buf)); |
| 569 | return dec; |
| 570 | } else { |
| 571 | serverPanic("Unknown encoding type"); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | robj_roptr getDecodedObject(robj_roptr o) { |
| 576 | return getDecodedObject(o.unsafe_robjcast()); |
no test coverage detected