Commit 9f6b430b authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Simplify prefix_cmp.

parent 6d99bd57
......@@ -494,25 +494,22 @@ enum prefix_status
prefix_cmp(const unsigned char *p1, unsigned char plen1,
const unsigned char *p2, unsigned char plen2)
{
int min = MIN(plen1, plen2);
unsigned char mask = 0xFF;
int i = 0;
int plen = MIN(plen1, plen2);
while(i < min / 8) {
if(p1[i] != p2[i])
if(memcmp(p1, p2, plen / 8) != 0)
return PST_DISJOINT;
i++;
}
min -= i * 8;
if(min != 0) {
mask <<= 8 - min;
if(plen % 8 != 0) {
int i = plen / 8 + 1;
unsigned char mask = (0xFF << (plen % 8)) & 0xFF;
if((p1[i] & mask) != (p2[i] & mask))
return PST_DISJOINT;
}
if(plen1 < plen2)
return PST_LESS_SPECIFIC;
if(plen1 > plen2)
else if(plen1 > plen2)
return PST_MORE_SPECIFIC;
else
return PST_EQUALS;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment