@@ -545,8 +545,6 @@ void hincrbyCommand(client *c) {
545545 server .dirty ++ ;
546546}
547547
548- /* XXX From here. */
549-
550548void hincrbyfloatCommand (client * c ) {
551549 double value , incr ;
552550 long long ll ;
@@ -593,7 +591,9 @@ void hincrbyfloatCommand(client *c) {
593591 decrRefCount (newobj );
594592}
595593
596- static void addHashFieldToReply (client * c , robj * o , robj * field ) {
594+ /* XXX From here. */
595+
596+ static void addHashFieldToReply (client * c , robj * o , sds field ) {
597597 int ret ;
598598
599599 if (o == NULL ) {
@@ -618,15 +618,11 @@ static void addHashFieldToReply(client *c, robj *o, robj *field) {
618618 }
619619
620620 } else if (o -> encoding == OBJ_ENCODING_HT ) {
621- robj * value ;
622-
623- ret = hashTypeGetFromHashTable (o , field , & value );
624- if (ret < 0 ) {
621+ sds value = hashTypeGetFromHashTable (o , field );
622+ if (value == NULL )
625623 addReply (c , shared .nullbulk );
626- } else {
627- addReplyBulk (c , value );
628- }
629-
624+ else
625+ addReplyBulkCBuffer (c , value , sdslen (value ));
630626 } else {
631627 serverPanic ("Unknown hash encoding" );
632628 }
@@ -638,7 +634,7 @@ void hgetCommand(client *c) {
638634 if ((o = lookupKeyReadOrReply (c ,c -> argv [1 ],shared .nullbulk )) == NULL ||
639635 checkType (c ,o ,OBJ_HASH )) return ;
640636
641- addHashFieldToReply (c , o , c -> argv [2 ]);
637+ addHashFieldToReply (c , o , c -> argv [2 ]-> ptr );
642638}
643639
644640void hmgetCommand (client * c ) {
@@ -655,7 +651,7 @@ void hmgetCommand(client *c) {
655651
656652 addReplyMultiBulkLen (c , c -> argc - 2 );
657653 for (i = 2 ; i < c -> argc ; i ++ ) {
658- addHashFieldToReply (c , o , c -> argv [i ]);
654+ addHashFieldToReply (c , o , c -> argv [i ]-> ptr );
659655 }
660656}
661657
@@ -667,7 +663,7 @@ void hdelCommand(client *c) {
667663 checkType (c ,o ,OBJ_HASH )) return ;
668664
669665 for (j = 2 ; j < c -> argc ; j ++ ) {
670- if (hashTypeDelete (o ,c -> argv [j ])) {
666+ if (hashTypeDelete (o ,c -> argv [j ]-> ptr )) {
671667 deleted ++ ;
672668 if (hashTypeLength (o ) == 0 ) {
673669 dbDelete (c -> db ,c -> argv [1 ]);
@@ -701,7 +697,7 @@ void hstrlenCommand(client *c) {
701697
702698 if ((o = lookupKeyReadOrReply (c ,c -> argv [1 ],shared .czero )) == NULL ||
703699 checkType (c ,o ,OBJ_HASH )) return ;
704- addReplyLongLong (c ,hashTypeGetValueLength (o ,c -> argv [2 ]));
700+ addReplyLongLong (c ,hashTypeGetValueLength (o ,c -> argv [2 ]-> ptr ));
705701}
706702
707703static void addHashIteratorCursorToReply (client * c , hashTypeIterator * hi , int what ) {
@@ -711,18 +707,13 @@ static void addHashIteratorCursorToReply(client *c, hashTypeIterator *hi, int wh
711707 long long vll = LLONG_MAX ;
712708
713709 hashTypeCurrentFromZiplist (hi , what , & vstr , & vlen , & vll );
714- if (vstr ) {
710+ if (vstr )
715711 addReplyBulkCBuffer (c , vstr , vlen );
716- } else {
712+ else
717713 addReplyBulkLongLong (c , vll );
718- }
719-
720714 } else if (hi -> encoding == OBJ_ENCODING_HT ) {
721- robj * value ;
722-
723- hashTypeCurrentFromHashTable (hi , what , & value );
724- addReplyBulk (c , value );
725-
715+ sds value = hashTypeCurrentFromHashTable (hi , what );
716+ addReplyBulkCBuffer (c , value , sdslen (value ));
726717 } else {
727718 serverPanic ("Unknown hash encoding" );
728719 }
@@ -776,7 +767,7 @@ void hexistsCommand(client *c) {
776767 if ((o = lookupKeyReadOrReply (c ,c -> argv [1 ],shared .czero )) == NULL ||
777768 checkType (c ,o ,OBJ_HASH )) return ;
778769
779- addReply (c , hashTypeExists (o ,c -> argv [2 ]) ? shared .cone : shared .czero );
770+ addReply (c , hashTypeExists (o ,c -> argv [2 ]-> ptr ) ? shared .cone : shared .czero );
780771}
781772
782773void hscanCommand (client * c ) {
0 commit comments