From: Howard Chu Date: Tue, 1 Jan 2002 04:43:03 +0000 (+0000) Subject: Optimize ISSPACE checks in UTF8StringNormalize X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~386 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3d8d9344ddf4ea564b8d976818eb2147a1e72ffd;p=openldap Optimize ISSPACE checks in UTF8StringNormalize --- diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 4759971ccc..302218833a 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -493,12 +493,14 @@ UTF8StringNormalize( struct berval *normalized ) { char *p, *q, *s; + int len = 0; p = val->bv_val; /* Ignore initial whitespace */ - while ( ldap_utf8_isspace( p ) ) { - LDAP_UTF8_INCR( p ); + /* All space is ASCII. All ASCII is 1 byte */ + while ( ASCII_SPACE( *p ) ) { + p++; } if( *p == '\0' ) { @@ -513,31 +515,28 @@ UTF8StringNormalize( s = NULL; while ( *p ) { - int len; - - if ( ldap_utf8_isspace( p ) ) { - len = LDAP_UTF8_COPY(q,p); - s=q; - p+=len; - q+=len; + q += len; + if ( ASCII_SPACE( *p ) ) { + s = q - len; + len = 1; + *q = *p++; /* Ignore the extra whitespace */ - while ( ldap_utf8_isspace( p ) ) { - LDAP_UTF8_INCR( p ); + while ( ASCII_SPACE( *p ) ) { + p++; } } else { len = LDAP_UTF8_COPY(q,p); s=NULL; p+=len; - q+=len; } } assert( normalized->bv_val < p ); - assert( q <= p ); + assert( q+len <= p ); /* cannot start with a space */ - assert( !ldap_utf8_isspace(normalized->bv_val) ); + assert( !ASCII_SPACE(normalized->bv_val[0]) ); /* * If the string ended in space, backup the pointer one @@ -550,7 +549,9 @@ UTF8StringNormalize( } /* cannot end with a space */ - assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) ); + assert( !ASCII_SPACE( *q ) ); + + q += len; /* null terminate */ *q = '\0'; @@ -560,7 +561,7 @@ UTF8StringNormalize( return LDAP_SUCCESS; } -/* Returns Unicode cannonically normalized copy of a substring assertion +/* Returns Unicode canonically normalized copy of a substring assertion * Skipping attribute description */ static SubstringsAssertion * UTF8SubstringsassertionNormalize(