Find pointer to the first element contained in the specified lex range. * Returns NULL when no element is contained in the range. */
| 951 | /* Find pointer to the first element contained in the specified lex range. |
| 952 | * Returns NULL when no element is contained in the range. */ |
| 953 | unsigned char *zzlFirstInLexRange(unsigned char *zl, zlexrangespec *range) { |
| 954 | unsigned char *eptr = ziplistIndex(zl,0), *sptr; |
| 955 | |
| 956 | /* If everything is out of range, return early. */ |
| 957 | if (!zzlIsInLexRange(zl,range)) return NULL; |
| 958 | |
| 959 | while (eptr != NULL) { |
| 960 | if (zzlLexValueGteMin(eptr,range)) { |
| 961 | /* Check if score <= max. */ |
| 962 | if (zzlLexValueLteMax(eptr,range)) |
| 963 | return eptr; |
| 964 | return NULL; |
| 965 | } |
| 966 | |
| 967 | /* Move to next element. */ |
| 968 | sptr = ziplistNext(zl,eptr); /* This element score. Skip it. */ |
| 969 | serverAssert(sptr != NULL); |
| 970 | eptr = ziplistNext(zl,sptr); /* Next element. */ |
| 971 | } |
| 972 | |
| 973 | return NULL; |
| 974 | } |
| 975 | |
| 976 | /* Find pointer to the last element contained in the specified lex range. |
| 977 | * Returns NULL when no element is contained in the range. */ |
no test coverage detected