mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
Second set of inline optimisation fixes from Ying Chen <ying@almaden.ibm.com>.
Stop makeing function calls for every use of skip_multibyte_char. This function is called several *million* times during a NetBench run :-). Jeremy.
This commit is contained in:
parent
fc0219c7cc
commit
e5a3deba46
@ -427,8 +427,8 @@ static void fixtarname(char *tptr, char *fp, int l)
|
||||
*tptr++='.';
|
||||
|
||||
while (l > 0) {
|
||||
int skip;
|
||||
if((skip = skip_multibyte_char( *fp)) != 0) {
|
||||
int skip = get_character_len(*fp);
|
||||
if(skip != 0) {
|
||||
if (skip == 2) {
|
||||
*tptr++ = *fp++;
|
||||
*tptr++ = *fp++;
|
||||
@ -885,8 +885,8 @@ static void unfixtarname(char *tptr, char *fp, int l, BOOL first)
|
||||
}
|
||||
|
||||
while (l > 0) {
|
||||
int skip;
|
||||
if(( skip = skip_multibyte_char( *fp )) != 0) {
|
||||
int skip = get_character_len(*fp);
|
||||
if(skip != 0) {
|
||||
if (skip == 2) {
|
||||
*tptr++ = *fp++;
|
||||
*tptr++ = *fp++;
|
||||
|
@ -119,7 +119,6 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces);
|
||||
/*The following definitions come from lib/kanji.c */
|
||||
|
||||
void interpret_coding_system(char *str);
|
||||
BOOL is_multibyte_codepage(void);
|
||||
void initialize_multibyte_vectors( int client_codepage);
|
||||
|
||||
/*The following definitions come from lib/md4.c */
|
||||
|
@ -1699,6 +1699,11 @@ enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};
|
||||
#define DEFAULT_CLIENT_CODE_PAGE MSDOS_LATIN_1_CODEPAGE
|
||||
#endif /* KANJI */
|
||||
|
||||
/* Global val set if multibyte codepage. */
|
||||
extern int global_is_multibyte_codepage;
|
||||
|
||||
#define get_character_len(x) (global_is_multibyte_codepage ? skip_multibyte_char((x)) : 0)
|
||||
|
||||
/*
|
||||
* Size of buffer to use when moving files across filesystems.
|
||||
*/
|
||||
|
@ -80,6 +80,8 @@ int (*is_multibyte_char_1)(char) = is_kanji_multibyte_char_1;
|
||||
|
||||
#endif /* KANJI */
|
||||
|
||||
BOOL global_is_multibyte_codepage = False;
|
||||
|
||||
/* jis si/so sequence */
|
||||
static char jis_kso = JIS_KSO;
|
||||
static char jis_ksi = JIS_KSI;
|
||||
@ -1162,17 +1164,6 @@ static BOOL not_multibyte_char_1(char c)
|
||||
return False;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Function to determine if we are in a multibyte code page.
|
||||
*******************************************************************/
|
||||
|
||||
static BOOL is_multibyte_codepage_val = False;
|
||||
|
||||
BOOL is_multibyte_codepage(void)
|
||||
{
|
||||
return is_multibyte_codepage_val;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Setup the function pointers for the functions that are replaced
|
||||
when multi-byte codepages are used.
|
||||
@ -1193,7 +1184,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
||||
multibyte_strtok = sj_strtok;
|
||||
_skip_multibyte_char = skip_kanji_multibyte_char;
|
||||
is_multibyte_char_1 = is_kanji_multibyte_char_1;
|
||||
is_multibyte_codepage_val = True;
|
||||
global_is_multibyte_codepage = True;
|
||||
break;
|
||||
case HANGUL_CODEPAGE:
|
||||
multibyte_strchr = generic_multibyte_strchr;
|
||||
@ -1202,7 +1193,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
||||
multibyte_strtok = generic_multibyte_strtok;
|
||||
_skip_multibyte_char = skip_generic_multibyte_char;
|
||||
is_multibyte_char_1 = hangul_is_multibyte_char_1;
|
||||
is_multibyte_codepage_val = True;
|
||||
global_is_multibyte_codepage = True;
|
||||
break;
|
||||
case BIG5_CODEPAGE:
|
||||
multibyte_strchr = generic_multibyte_strchr;
|
||||
@ -1211,7 +1202,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
||||
multibyte_strtok = generic_multibyte_strtok;
|
||||
_skip_multibyte_char = skip_generic_multibyte_char;
|
||||
is_multibyte_char_1 = big5_is_multibyte_char_1;
|
||||
is_multibyte_codepage_val = True;
|
||||
global_is_multibyte_codepage = True;
|
||||
break;
|
||||
case SIMPLIFIED_CHINESE_CODEPAGE:
|
||||
multibyte_strchr = generic_multibyte_strchr;
|
||||
@ -1220,7 +1211,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
||||
multibyte_strtok = generic_multibyte_strtok;
|
||||
_skip_multibyte_char = skip_generic_multibyte_char;
|
||||
is_multibyte_char_1 = simpch_is_multibyte_char_1;
|
||||
is_multibyte_codepage_val = True;
|
||||
global_is_multibyte_codepage = True;
|
||||
break;
|
||||
/*
|
||||
* Single char size code page.
|
||||
@ -1232,7 +1223,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
||||
multibyte_strtok = (char *(*)(char *, const char *)) strtok;
|
||||
_skip_multibyte_char = skip_non_multibyte_char;
|
||||
is_multibyte_char_1 = not_multibyte_char_1;
|
||||
is_multibyte_codepage_val = False;
|
||||
global_is_multibyte_codepage = False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ void strlower(char *s)
|
||||
else
|
||||
#endif /* KANJI_WIN95_COMPATIBILITY */
|
||||
{
|
||||
size_t skip = skip_multibyte_char( *s );
|
||||
size_t skip = get_character_len( *s );
|
||||
if( skip != 0 )
|
||||
s += skip;
|
||||
else
|
||||
@ -396,7 +396,7 @@ void strupper(char *s)
|
||||
else
|
||||
#endif /* KANJI_WIN95_COMPATIBILITY */
|
||||
{
|
||||
size_t skip = skip_multibyte_char( *s );
|
||||
size_t skip = get_character_len( *s );
|
||||
if( skip != 0 )
|
||||
s += skip;
|
||||
else
|
||||
@ -440,17 +440,29 @@ BOOL strisnormal(char *s)
|
||||
void string_replace(char *s,char oldc,char newc)
|
||||
{
|
||||
size_t skip;
|
||||
while (*s)
|
||||
{
|
||||
skip = skip_multibyte_char( *s );
|
||||
if( skip != 0 )
|
||||
s += skip;
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* sbcs optimization.
|
||||
*/
|
||||
if(!global_is_multibyte_codepage) {
|
||||
while (*s) {
|
||||
if (oldc == *s)
|
||||
*s = newc;
|
||||
s++;
|
||||
}
|
||||
} else {
|
||||
while (*s)
|
||||
{
|
||||
skip = get_character_len( *s );
|
||||
if( skip != 0 )
|
||||
s += skip;
|
||||
else
|
||||
{
|
||||
if (oldc == *s)
|
||||
*s = newc;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -476,10 +488,17 @@ size_t str_charnum(const char *s)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
while (*s != '\0') {
|
||||
int skip = skip_multibyte_char(*s);
|
||||
s += (skip ? skip : 1);
|
||||
len++;
|
||||
/*
|
||||
* sbcs optimization.
|
||||
*/
|
||||
if(!global_is_multibyte_codepage) {
|
||||
return strlen(s);
|
||||
} else {
|
||||
while (*s != '\0') {
|
||||
int skip = get_character_len(*s);
|
||||
s += (skip ? skip : 1);
|
||||
len++;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
@ -518,7 +537,7 @@ BOOL trim_string(char *s,const char *front,const char *back)
|
||||
|
||||
if(back_len)
|
||||
{
|
||||
if(!is_multibyte_codepage())
|
||||
if(!global_is_multibyte_codepage)
|
||||
{
|
||||
s_len = strlen(s);
|
||||
while ((s_len >= back_len) &&
|
||||
@ -552,11 +571,20 @@ BOOL trim_string(char *s,const char *front,const char *back)
|
||||
size_t charcount = 0;
|
||||
char *mbp = s;
|
||||
|
||||
while(charcount < (mb_s_len - mb_back_len))
|
||||
{
|
||||
size_t skip = skip_multibyte_char(*mbp);
|
||||
mbp += (skip ? skip : 1);
|
||||
charcount++;
|
||||
/*
|
||||
* sbcs optimization.
|
||||
*/
|
||||
if(!global_is_multibyte_codepage) {
|
||||
while(charcount < (mb_s_len - mb_back_len)) {
|
||||
mbp += 1;
|
||||
charcount++;
|
||||
}
|
||||
} else {
|
||||
while(charcount < (mb_s_len - mb_back_len)) {
|
||||
size_t skip = skip_multibyte_char(*mbp);
|
||||
mbp += (skip ? skip : 1);
|
||||
charcount++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -615,7 +643,7 @@ BOOL strhasupper(const char *s)
|
||||
else
|
||||
#endif /* KANJI_WIN95_COMPATIBILITY */
|
||||
{
|
||||
size_t skip = skip_multibyte_char( *s );
|
||||
size_t skip = get_character_len( *s );
|
||||
if( skip != 0 )
|
||||
s += skip;
|
||||
else {
|
||||
@ -670,7 +698,7 @@ BOOL strhaslower(const char *s)
|
||||
else
|
||||
#endif /* KANJI_WIN95_COMPATIBILITY */
|
||||
{
|
||||
size_t skip = skip_multibyte_char( *s );
|
||||
size_t skip = get_character_len( *s );
|
||||
if( skip != 0 )
|
||||
s += skip;
|
||||
else {
|
||||
@ -720,7 +748,7 @@ size_t count_chars(const char *s,char c)
|
||||
{
|
||||
while (*s)
|
||||
{
|
||||
size_t skip = skip_multibyte_char( *s );
|
||||
size_t skip = get_character_len( *s );
|
||||
if( skip != 0 )
|
||||
s += skip;
|
||||
else {
|
||||
@ -774,7 +802,7 @@ BOOL str_is_all(const char *s,char c)
|
||||
{
|
||||
while (*s)
|
||||
{
|
||||
size_t skip = skip_multibyte_char( *s );
|
||||
size_t skip = get_character_len( *s );
|
||||
if( skip != 0 )
|
||||
s += skip;
|
||||
else {
|
||||
|
@ -54,7 +54,7 @@ int dos_PutUniCode(char *dst,const char *src, ssize_t len)
|
||||
{
|
||||
int ret = 0;
|
||||
while (*src && (len > 2)) {
|
||||
size_t skip = skip_multibyte_char(*src);
|
||||
size_t skip = get_character_len(*src);
|
||||
smb_ucs2_t val = (*src & 0xff);
|
||||
|
||||
/*
|
||||
@ -272,7 +272,7 @@ size_t dos_struni2(char *dst, const char *src, size_t max_len)
|
||||
|
||||
if (src != NULL) {
|
||||
for (; *src && len < max_len-2; len++, dst +=2) {
|
||||
size_t skip = skip_multibyte_char(*src);
|
||||
size_t skip = get_character_len(*src);
|
||||
smb_ucs2_t val = (*src & 0xff);
|
||||
|
||||
/*
|
||||
@ -615,7 +615,7 @@ smb_ucs2_t *multibyte_to_unicode(smb_ucs2_t *dst, const char *src,
|
||||
dst_len /= sizeof(smb_ucs2_t); /* Convert to smb_ucs2_t units. */
|
||||
|
||||
for(i = 0; (i < (dst_len - 1)) && src[i];) {
|
||||
size_t skip = skip_multibyte_char(*src);
|
||||
size_t skip = get_character_len(*src);
|
||||
smb_ucs2_t val = (*src & 0xff);
|
||||
|
||||
/*
|
||||
|
@ -182,7 +182,7 @@ static int Continuation( char *line, int pos )
|
||||
/* we should recognize if `\` is part of a multibyte character or not. */
|
||||
while(pos2 <= pos) {
|
||||
size_t skip = 0;
|
||||
skip = skip_multibyte_char(line[pos2]);
|
||||
skip = get_character_len(line[pos2]);
|
||||
if (skip) {
|
||||
pos2 += skip;
|
||||
} else if (pos == pos2) {
|
||||
|
@ -255,7 +255,7 @@ static BOOL is_illegal_name( char *name )
|
||||
s = (unsigned char *)name;
|
||||
while( *s )
|
||||
{
|
||||
skip = skip_multibyte_char( *s );
|
||||
skip = get_character_len( *s );
|
||||
if( skip != 0 )
|
||||
{
|
||||
s += skip;
|
||||
@ -374,7 +374,7 @@ BOOL is_8_3( char *fname, BOOL check_case )
|
||||
dot_pos = NULL;
|
||||
while( *p )
|
||||
{
|
||||
if( (skip = skip_multibyte_char( *p )) != 0 )
|
||||
if( (skip = get_character_len( *p )) != 0 )
|
||||
p += skip;
|
||||
else
|
||||
{
|
||||
@ -878,7 +878,7 @@ void mangle_name_83( char *s)
|
||||
*p++ = 0;
|
||||
while( *p && extlen < 3 )
|
||||
{
|
||||
skip = skip_multibyte_char( *p );
|
||||
skip = get_character_len( *p );
|
||||
switch( skip )
|
||||
{
|
||||
case 2:
|
||||
@ -912,7 +912,7 @@ void mangle_name_83( char *s)
|
||||
|
||||
while( *p && baselen < 5 )
|
||||
{
|
||||
skip = skip_multibyte_char(*p);
|
||||
skip = get_character_len(*p);
|
||||
switch( skip )
|
||||
{
|
||||
case 2:
|
||||
|
@ -1334,7 +1334,7 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
||||
p = mask;
|
||||
while(*p)
|
||||
{
|
||||
if((skip = skip_multibyte_char( *p )) != 0 )
|
||||
if((skip = get_character_len( *p )) != 0 )
|
||||
{
|
||||
p += skip;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user