From: Howard Chu Date: Wed, 26 Dec 2001 14:36:02 +0000 (+0000) Subject: Precompute syn_oidlen and mr_oidlen X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~501 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3da3be81286d56398f9dfd393212052ed5e77aac;p=openldap Precompute syn_oidlen and mr_oidlen --- diff --git a/servers/slapd/mr.c b/servers/slapd/mr.c index 1b693a5c6e..c4f7701ca7 100644 --- a/servers/slapd/mr.c +++ b/servers/slapd/mr.c @@ -139,6 +139,7 @@ mr_add( smr = (MatchingRule *) ch_calloc( 1, sizeof(MatchingRule) ); AC_MEMCPY( &smr->smr_mrule, mr, sizeof(LDAPMatchingRule)); + smr->smr_oidlen = strlen( mr->mr_oid ); smr->smr_usage = usage; smr->smr_convert = convert; smr->smr_normalize = normalize; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 4dd9022c22..514c3c8610 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -144,8 +144,8 @@ static int octetStringIndexer( keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; for( i=0; values[i] != NULL; i++ ) { HASH_Init( &HASHcontext ); @@ -190,8 +190,8 @@ static int octetStringFilter( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; keys = ch_malloc( sizeof( struct berval * ) * 2 ); @@ -1190,8 +1190,8 @@ static int caseExactIgnoreIndexer( keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; casefold = strcmp( mr->smr_oid, caseExactMatchOID ) ? UTF8_CASEFOLD : UTF8_NOCASEFOLD; @@ -1244,8 +1244,8 @@ static int caseExactIgnoreFilter( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; casefold = strcmp( mr->smr_oid, caseExactMatchOID ) ? UTF8_CASEFOLD : UTF8_NOCASEFOLD; @@ -1365,8 +1365,8 @@ static int caseExactIgnoreSubstringsIndexer( keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; nkeys=0; for( i=0; values[i] != NULL; i++ ) { @@ -1531,8 +1531,8 @@ static int caseExactIgnoreSubstringsFilter( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); nkeys = 0; @@ -2231,8 +2231,8 @@ static int caseExactIA5Indexer( keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; for( i=0; values[i] != NULL; i++ ) { struct berval *value = values[i]; @@ -2277,8 +2277,8 @@ static int caseExactIA5Filter( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; value = (struct berval *) assertValue; @@ -2366,8 +2366,8 @@ static int caseExactIA5SubstringsIndexer( keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; nkeys=0; for( i=0; values[i] != NULL; i++ ) { @@ -2515,8 +2515,8 @@ static int caseExactIA5SubstringsFilter( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); nkeys = 0; @@ -2797,8 +2797,8 @@ static int caseIgnoreIA5Indexer( keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; for( i=0; values[i] != NULL; i++ ) { struct berval *value = ber_bvdup( values[i] ); @@ -2846,8 +2846,8 @@ static int caseIgnoreIA5Filter( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; value = ber_bvdup( (struct berval *) assertValue ); ldap_pvt_str2upper( value->bv_val ); @@ -2939,8 +2939,8 @@ static int caseIgnoreIA5SubstringsIndexer( keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; nkeys=0; for( i=0; values[i] != NULL; i++ ) { @@ -3092,8 +3092,8 @@ static int caseIgnoreIA5SubstringsFilter( digest.bv_val = HASHdigest; digest.bv_len = sizeof(HASHdigest); - slen = strlen( syntax->ssyn_oid ); - mlen = strlen( mr->smr_oid ); + slen = syntax->ssyn_oidlen; + mlen = mr->smr_oidlen; keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) ); nkeys = 0; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index ef156cbf33..5955aef7a0 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -254,6 +254,7 @@ typedef struct slap_syntax { #define ssyn_oid ssyn_syn.syn_oid #define ssyn_desc ssyn_syn.syn_desc #define ssyn_extensions ssyn_syn.syn_extensions + ber_len_t ssyn_oidlen; unsigned ssyn_flags; @@ -326,6 +327,7 @@ typedef int slap_mr_filter_func LDAP_P(( typedef struct slap_matching_rule { LDAPMatchingRule smr_mrule; + ber_len_t smr_oidlen; slap_mask_t smr_usage; #define SLAP_MR_TYPE_MASK 0xFF00U diff --git a/servers/slapd/syntax.c b/servers/slapd/syntax.c index 07bd49730d..1e637bf018 100644 --- a/servers/slapd/syntax.c +++ b/servers/slapd/syntax.c @@ -134,6 +134,7 @@ syn_add( ssyn->ssyn_next = NULL; + ssyn->ssyn_oidlen = strlen(syn->syn_oid); ssyn->ssyn_flags = flags; ssyn->ssyn_validate = validate; ssyn->ssyn_normalize = normalize;