Returns if there is a part of the zset is in range. Should only be used * internally by zzlFirstInRange and zzlLastInRange. */
| 928 | /* Returns if there is a part of the zset is in range. Should only be used |
| 929 | * internally by zzlFirstInRange and zzlLastInRange. */ |
| 930 | int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) { |
| 931 | unsigned char *p; |
| 932 | |
| 933 | /* Test for ranges that will always be empty. */ |
| 934 | int cmp = sdscmplex(range->min,range->max); |
| 935 | if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex))) |
| 936 | return 0; |
| 937 | |
| 938 | p = ziplistIndex(zl,-2); /* Last element. */ |
| 939 | if (p == NULL) return 0; |
| 940 | if (!zzlLexValueGteMin(p,range)) |
| 941 | return 0; |
| 942 | |
| 943 | p = ziplistIndex(zl,0); /* First element. */ |
| 944 | serverAssert(p != NULL); |
| 945 | if (!zzlLexValueLteMax(p,range)) |
| 946 | return 0; |
| 947 | |
| 948 | return 1; |
| 949 | } |
| 950 | |
| 951 | /* Find pointer to the first element contained in the specified lex range. |
| 952 | * Returns NULL when no element is contained in the range. */ |
no test coverage detected