mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-01-31 10:49:27 -05:00
couple percent shaved off in compress_tree_lookup and dname_lab_cmp.
git-svn-id: file:///svn/unbound/trunk@980 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
6591aab69f
commit
104a7fb3ea
3 changed files with 35 additions and 11 deletions
|
|
@ -1,5 +1,8 @@
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -420,7 +420,6 @@ memlowercmp(uint8_t* p1, uint8_t* p2, uint8_t len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
dname_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs)
|
||||
{
|
||||
|
|
@ -428,7 +427,6 @@ 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) {
|
||||
|
|
@ -460,13 +458,35 @@ dname_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs)
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ compress_tree_search(struct compress_tree_node** tree, uint8_t* dname,
|
|||
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) {
|
||||
|
|
@ -113,15 +113,16 @@ compress_tree_search(struct compress_tree_node** tree, uint8_t* dname,
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue