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. */
| 517 | /* Get a decoded version of an encoded object (returned as a new object). |
| 518 | * If the object is already raw-encoded just increment the ref count. */ |
| 519 | robj *getDecodedObject(robj *o) { |
| 520 | robj *dec; |
| 521 | |
| 522 | if (sdsEncodedObject(o)) { |
| 523 | incrRefCount(o); |
| 524 | return o; |
| 525 | } |
| 526 | if (o->type == OBJ_STRING && o->encoding == OBJ_ENCODING_INT) { |
| 527 | char buf[32]; |
| 528 | |
| 529 | ll2string(buf,32,(long)o->ptr); |
| 530 | dec = createStringObject(buf,strlen(buf)); |
| 531 | return dec; |
| 532 | } else { |
| 533 | serverPanic("Unknown encoding type"); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | /* Compare two string objects via strcmp() or strcoll() depending on flags. |
| 538 | * Note that the objects may be integer-encoded. In such a case we |
no test coverage detected