mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
remove the call to dns_name_getlabel(), since the dns_name_toregion() macro
is faster.
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: compress.c,v 1.43 2001/01/09 21:50:42 bwelling Exp $ */
|
/* $Id: compress.c,v 1.44 2001/01/23 02:19:48 bwelling Exp $ */
|
||||||
|
|
||||||
#define DNS_NAME_USEINLINE 1
|
#define DNS_NAME_USEINLINE 1
|
||||||
|
|
||||||
@@ -149,17 +149,26 @@ dns_compress_findglobal(dns_compress_t *cctx, dns_name_t *name,
|
|||||||
return (ISC_TRUE);
|
return (ISC_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int
|
||||||
|
name_length(dns_name_t *name) {
|
||||||
|
isc_region_t r;
|
||||||
|
dns_name_toregion(name, &r);
|
||||||
|
return (r.length);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_compress_add(dns_compress_t *cctx, dns_name_t *name, dns_name_t *prefix,
|
dns_compress_add(dns_compress_t *cctx, dns_name_t *name, dns_name_t *prefix,
|
||||||
isc_uint16_t offset)
|
isc_uint16_t offset)
|
||||||
{
|
{
|
||||||
dns_name_t tname, nname;
|
dns_name_t tname, nname;
|
||||||
dns_label_t label;
|
|
||||||
unsigned int start;
|
unsigned int start;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
unsigned int hash;
|
unsigned int hash;
|
||||||
dns_compressnode_t *node;
|
dns_compressnode_t *node;
|
||||||
|
unsigned int length;
|
||||||
|
unsigned int tlength;
|
||||||
|
isc_uint16_t toffset;
|
||||||
|
|
||||||
REQUIRE(VALID_CCTX(cctx));
|
REQUIRE(VALID_CCTX(cctx));
|
||||||
REQUIRE(dns_name_isabsolute(name));
|
REQUIRE(dns_name_isabsolute(name));
|
||||||
@@ -172,12 +181,15 @@ dns_compress_add(dns_compress_t *cctx, dns_name_t *name, dns_name_t *prefix,
|
|||||||
if (dns_name_isabsolute(prefix))
|
if (dns_name_isabsolute(prefix))
|
||||||
count--;
|
count--;
|
||||||
start = 0;
|
start = 0;
|
||||||
|
length = name_length(name);
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
if (offset >= 0x4000)
|
if (offset >= 0x4000)
|
||||||
break;
|
break;
|
||||||
dns_name_getlabelsequence(name, start, n, &tname);
|
dns_name_getlabelsequence(name, start, n, &tname);
|
||||||
hash = dns_name_hash(&tname, ISC_FALSE) %
|
hash = dns_name_hash(&tname, ISC_FALSE) %
|
||||||
DNS_COMPRESS_TABLESIZE;
|
DNS_COMPRESS_TABLESIZE;
|
||||||
|
tlength = name_length(&tname);
|
||||||
|
toffset = (isc_uint16_t)(offset + (length - tlength));
|
||||||
/*
|
/*
|
||||||
* Look for the name in the hash bucket. If it's there,
|
* Look for the name in the hash bucket. If it's there,
|
||||||
* we're done.
|
* we're done.
|
||||||
@@ -200,12 +212,10 @@ dns_compress_add(dns_compress_t *cctx, dns_name_t *name, dns_name_t *prefix,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
node->count = cctx->count++;
|
node->count = cctx->count++;
|
||||||
node->offset = offset;
|
node->offset = toffset;
|
||||||
dns_name_toregion(&tname, &node->r);
|
dns_name_toregion(&tname, &node->r);
|
||||||
node->next = cctx->table[hash];
|
node->next = cctx->table[hash];
|
||||||
cctx->table[hash] = node;
|
cctx->table[hash] = node;
|
||||||
dns_name_getlabel(&tname, 0, &label);
|
|
||||||
offset += label.length;
|
|
||||||
start++;
|
start++;
|
||||||
n--;
|
n--;
|
||||||
count--;
|
count--;
|
||||||
|
Reference in New Issue
Block a user