Return (by reference) the score of the specified member of the sorted set * storing it into *score. If the element does not exist C_ERR is returned * otherwise C_OK is returned and *score is correctly populated. * If 'zobj' or 'member' is NULL, C_ERR is returned. */
| 1261 | * otherwise C_OK is returned and *score is correctly populated. |
| 1262 | * If 'zobj' or 'member' is NULL, C_ERR is returned. */ |
| 1263 | int zsetScore(robj_roptr zobj, sds member, double *score) { |
| 1264 | if (!zobj || !member) return C_ERR; |
| 1265 | |
| 1266 | if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { |
| 1267 | if (zzlFind((unsigned char*)zobj->m_ptr, member, score) == NULL) return C_ERR; |
| 1268 | } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { |
| 1269 | zset *zs = (zset*)zobj->m_ptr; |
| 1270 | dictEntry *de = dictFind(zs->dict, member); |
| 1271 | if (de == NULL) return C_ERR; |
| 1272 | *score = *(double*)dictGetVal(de); |
| 1273 | } else { |
| 1274 | serverPanic("Unknown sorted set encoding"); |
| 1275 | } |
| 1276 | return C_OK; |
| 1277 | } |
| 1278 | |
| 1279 | /* Add a new element or update the score of an existing element in a sorted |
| 1280 | * set, regardless of its encoding. |
no test coverage detected