21 February 2008: Wouter
- speedup of root-delegation message encoding by 15%.
+ - minor speedup of compress tree_lookup, maybe 1%.
+ - speedup of dname_lab_cmp and memlowercmp - the top functions in
+ profiler output, maybe a couple percent when it matters.
20 February 2008: Wouter
- setup speec_cache for need-ldns-testns in dotests.
return 0;
}
-
int
dname_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs)
{
int atlabel = labs1;
int lastmlabs;
int lastdiff = 0;
- int c;
/* first skip so that we compare same label. */
if(labs1 > labs2) {
while(atlabel > labs2) {
lastdiff = -1;
else lastdiff = 1;
lastmlabs = atlabel;
- } else if((c=memlowercmp(d1, d2, len1)) != 0) {
- lastdiff = c;
- lastmlabs = atlabel;
+ d1 += len1;
+ d2 += len2;
+ } else {
+ /* memlowercmp is inlined here; or just like
+ * if((c=memlowercmp(d1, d2, len1)) != 0) {
+ * lastdiff = c;
+ * lastmlabs = atlabel; } apart from d1++,d2++ */
+ while(len1) {
+ if(*d1 != *d2 && tolower((int)*d1)
+ != tolower((int)*d2)) {
+ if(tolower((int)*d1) <
+ tolower((int)*d2)) {
+ lastdiff = -1;
+ lastmlabs = atlabel;
+ d1 += len1;
+ d2 += len1;
+ break;
+ }
+ lastdiff = 1;
+ lastmlabs = atlabel;
+ d1 += len1;
+ d2 += len1;
+ break; /* out of memlowercmp */
+ }
+ d1++;
+ d2++;
+ len1--;
+ }
}
-
- d1 += len1;
- d2 += len2;
atlabel--;
}
/* last difference atlabel number, so number of labels matching,
int c, n, closen=0;
struct compress_tree_node* p = *tree;
struct compress_tree_node* close = 0;
- *insertpt = tree;
+ struct compress_tree_node** prev = tree;
while(p) {
if((c = dname_lab_cmp(dname, labs, p->dname, p->labs, &n))
== 0) {
return 1;
}
if(c<0) {
- *insertpt = &p->left;
+ prev = &p->left;
p = p->left;
} else {
closen = n;
close = p; /* p->dname is smaller than dname */
- *insertpt = &p->right;
+ prev = &p->right;
p = p->right;
}
}
+ *insertpt = prev;
*matchlabels = closen;
*match = close;
return 0;