mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +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 used to be commit e5a3deba46ea2d4cb49a6c4b73edd766fe8b5a5c)
This commit is contained in:
parent
b5e7e4277d
commit
d867b86721
@ -427,8 +427,8 @@ static void fixtarname(char *tptr, char *fp, int l)
|
|||||||
*tptr++='.';
|
*tptr++='.';
|
||||||
|
|
||||||
while (l > 0) {
|
while (l > 0) {
|
||||||
int skip;
|
int skip = get_character_len(*fp);
|
||||||
if((skip = skip_multibyte_char( *fp)) != 0) {
|
if(skip != 0) {
|
||||||
if (skip == 2) {
|
if (skip == 2) {
|
||||||
*tptr++ = *fp++;
|
*tptr++ = *fp++;
|
||||||
*tptr++ = *fp++;
|
*tptr++ = *fp++;
|
||||||
@ -885,8 +885,8 @@ static void unfixtarname(char *tptr, char *fp, int l, BOOL first)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (l > 0) {
|
while (l > 0) {
|
||||||
int skip;
|
int skip = get_character_len(*fp);
|
||||||
if(( skip = skip_multibyte_char( *fp )) != 0) {
|
if(skip != 0) {
|
||||||
if (skip == 2) {
|
if (skip == 2) {
|
||||||
*tptr++ = *fp++;
|
*tptr++ = *fp++;
|
||||||
*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 */
|
/*The following definitions come from lib/kanji.c */
|
||||||
|
|
||||||
void interpret_coding_system(char *str);
|
void interpret_coding_system(char *str);
|
||||||
BOOL is_multibyte_codepage(void);
|
|
||||||
void initialize_multibyte_vectors( int client_codepage);
|
void initialize_multibyte_vectors( int client_codepage);
|
||||||
|
|
||||||
/*The following definitions come from lib/md4.c */
|
/*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
|
#define DEFAULT_CLIENT_CODE_PAGE MSDOS_LATIN_1_CODEPAGE
|
||||||
#endif /* KANJI */
|
#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.
|
* 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 */
|
#endif /* KANJI */
|
||||||
|
|
||||||
|
BOOL global_is_multibyte_codepage = False;
|
||||||
|
|
||||||
/* jis si/so sequence */
|
/* jis si/so sequence */
|
||||||
static char jis_kso = JIS_KSO;
|
static char jis_kso = JIS_KSO;
|
||||||
static char jis_ksi = JIS_KSI;
|
static char jis_ksi = JIS_KSI;
|
||||||
@ -1162,17 +1164,6 @@ static BOOL not_multibyte_char_1(char c)
|
|||||||
return False;
|
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
|
Setup the function pointers for the functions that are replaced
|
||||||
when multi-byte codepages are used.
|
when multi-byte codepages are used.
|
||||||
@ -1193,7 +1184,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
|||||||
multibyte_strtok = sj_strtok;
|
multibyte_strtok = sj_strtok;
|
||||||
_skip_multibyte_char = skip_kanji_multibyte_char;
|
_skip_multibyte_char = skip_kanji_multibyte_char;
|
||||||
is_multibyte_char_1 = is_kanji_multibyte_char_1;
|
is_multibyte_char_1 = is_kanji_multibyte_char_1;
|
||||||
is_multibyte_codepage_val = True;
|
global_is_multibyte_codepage = True;
|
||||||
break;
|
break;
|
||||||
case HANGUL_CODEPAGE:
|
case HANGUL_CODEPAGE:
|
||||||
multibyte_strchr = generic_multibyte_strchr;
|
multibyte_strchr = generic_multibyte_strchr;
|
||||||
@ -1202,7 +1193,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
|||||||
multibyte_strtok = generic_multibyte_strtok;
|
multibyte_strtok = generic_multibyte_strtok;
|
||||||
_skip_multibyte_char = skip_generic_multibyte_char;
|
_skip_multibyte_char = skip_generic_multibyte_char;
|
||||||
is_multibyte_char_1 = hangul_is_multibyte_char_1;
|
is_multibyte_char_1 = hangul_is_multibyte_char_1;
|
||||||
is_multibyte_codepage_val = True;
|
global_is_multibyte_codepage = True;
|
||||||
break;
|
break;
|
||||||
case BIG5_CODEPAGE:
|
case BIG5_CODEPAGE:
|
||||||
multibyte_strchr = generic_multibyte_strchr;
|
multibyte_strchr = generic_multibyte_strchr;
|
||||||
@ -1211,7 +1202,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
|||||||
multibyte_strtok = generic_multibyte_strtok;
|
multibyte_strtok = generic_multibyte_strtok;
|
||||||
_skip_multibyte_char = skip_generic_multibyte_char;
|
_skip_multibyte_char = skip_generic_multibyte_char;
|
||||||
is_multibyte_char_1 = big5_is_multibyte_char_1;
|
is_multibyte_char_1 = big5_is_multibyte_char_1;
|
||||||
is_multibyte_codepage_val = True;
|
global_is_multibyte_codepage = True;
|
||||||
break;
|
break;
|
||||||
case SIMPLIFIED_CHINESE_CODEPAGE:
|
case SIMPLIFIED_CHINESE_CODEPAGE:
|
||||||
multibyte_strchr = generic_multibyte_strchr;
|
multibyte_strchr = generic_multibyte_strchr;
|
||||||
@ -1220,7 +1211,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
|||||||
multibyte_strtok = generic_multibyte_strtok;
|
multibyte_strtok = generic_multibyte_strtok;
|
||||||
_skip_multibyte_char = skip_generic_multibyte_char;
|
_skip_multibyte_char = skip_generic_multibyte_char;
|
||||||
is_multibyte_char_1 = simpch_is_multibyte_char_1;
|
is_multibyte_char_1 = simpch_is_multibyte_char_1;
|
||||||
is_multibyte_codepage_val = True;
|
global_is_multibyte_codepage = True;
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
* Single char size code page.
|
* Single char size code page.
|
||||||
@ -1232,7 +1223,7 @@ void initialize_multibyte_vectors( int client_codepage)
|
|||||||
multibyte_strtok = (char *(*)(char *, const char *)) strtok;
|
multibyte_strtok = (char *(*)(char *, const char *)) strtok;
|
||||||
_skip_multibyte_char = skip_non_multibyte_char;
|
_skip_multibyte_char = skip_non_multibyte_char;
|
||||||
is_multibyte_char_1 = not_multibyte_char_1;
|
is_multibyte_char_1 = not_multibyte_char_1;
|
||||||
is_multibyte_codepage_val = False;
|
global_is_multibyte_codepage = False;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ void strlower(char *s)
|
|||||||
else
|
else
|
||||||
#endif /* KANJI_WIN95_COMPATIBILITY */
|
#endif /* KANJI_WIN95_COMPATIBILITY */
|
||||||
{
|
{
|
||||||
size_t skip = skip_multibyte_char( *s );
|
size_t skip = get_character_len( *s );
|
||||||
if( skip != 0 )
|
if( skip != 0 )
|
||||||
s += skip;
|
s += skip;
|
||||||
else
|
else
|
||||||
@ -396,7 +396,7 @@ void strupper(char *s)
|
|||||||
else
|
else
|
||||||
#endif /* KANJI_WIN95_COMPATIBILITY */
|
#endif /* KANJI_WIN95_COMPATIBILITY */
|
||||||
{
|
{
|
||||||
size_t skip = skip_multibyte_char( *s );
|
size_t skip = get_character_len( *s );
|
||||||
if( skip != 0 )
|
if( skip != 0 )
|
||||||
s += skip;
|
s += skip;
|
||||||
else
|
else
|
||||||
@ -440,17 +440,29 @@ BOOL strisnormal(char *s)
|
|||||||
void string_replace(char *s,char oldc,char newc)
|
void string_replace(char *s,char oldc,char newc)
|
||||||
{
|
{
|
||||||
size_t skip;
|
size_t skip;
|
||||||
while (*s)
|
|
||||||
{
|
/*
|
||||||
skip = skip_multibyte_char( *s );
|
* sbcs optimization.
|
||||||
if( skip != 0 )
|
*/
|
||||||
s += skip;
|
if(!global_is_multibyte_codepage) {
|
||||||
else
|
while (*s) {
|
||||||
{
|
|
||||||
if (oldc == *s)
|
if (oldc == *s)
|
||||||
*s = newc;
|
*s = newc;
|
||||||
s++;
|
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;
|
size_t len = 0;
|
||||||
|
|
||||||
while (*s != '\0') {
|
/*
|
||||||
int skip = skip_multibyte_char(*s);
|
* sbcs optimization.
|
||||||
s += (skip ? skip : 1);
|
*/
|
||||||
len++;
|
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;
|
return len;
|
||||||
}
|
}
|
||||||
@ -518,7 +537,7 @@ BOOL trim_string(char *s,const char *front,const char *back)
|
|||||||
|
|
||||||
if(back_len)
|
if(back_len)
|
||||||
{
|
{
|
||||||
if(!is_multibyte_codepage())
|
if(!global_is_multibyte_codepage)
|
||||||
{
|
{
|
||||||
s_len = strlen(s);
|
s_len = strlen(s);
|
||||||
while ((s_len >= back_len) &&
|
while ((s_len >= back_len) &&
|
||||||
@ -552,11 +571,20 @@ BOOL trim_string(char *s,const char *front,const char *back)
|
|||||||
size_t charcount = 0;
|
size_t charcount = 0;
|
||||||
char *mbp = s;
|
char *mbp = s;
|
||||||
|
|
||||||
while(charcount < (mb_s_len - mb_back_len))
|
/*
|
||||||
{
|
* sbcs optimization.
|
||||||
size_t skip = skip_multibyte_char(*mbp);
|
*/
|
||||||
mbp += (skip ? skip : 1);
|
if(!global_is_multibyte_codepage) {
|
||||||
charcount++;
|
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
|
else
|
||||||
#endif /* KANJI_WIN95_COMPATIBILITY */
|
#endif /* KANJI_WIN95_COMPATIBILITY */
|
||||||
{
|
{
|
||||||
size_t skip = skip_multibyte_char( *s );
|
size_t skip = get_character_len( *s );
|
||||||
if( skip != 0 )
|
if( skip != 0 )
|
||||||
s += skip;
|
s += skip;
|
||||||
else {
|
else {
|
||||||
@ -670,7 +698,7 @@ BOOL strhaslower(const char *s)
|
|||||||
else
|
else
|
||||||
#endif /* KANJI_WIN95_COMPATIBILITY */
|
#endif /* KANJI_WIN95_COMPATIBILITY */
|
||||||
{
|
{
|
||||||
size_t skip = skip_multibyte_char( *s );
|
size_t skip = get_character_len( *s );
|
||||||
if( skip != 0 )
|
if( skip != 0 )
|
||||||
s += skip;
|
s += skip;
|
||||||
else {
|
else {
|
||||||
@ -720,7 +748,7 @@ size_t count_chars(const char *s,char c)
|
|||||||
{
|
{
|
||||||
while (*s)
|
while (*s)
|
||||||
{
|
{
|
||||||
size_t skip = skip_multibyte_char( *s );
|
size_t skip = get_character_len( *s );
|
||||||
if( skip != 0 )
|
if( skip != 0 )
|
||||||
s += skip;
|
s += skip;
|
||||||
else {
|
else {
|
||||||
@ -774,7 +802,7 @@ BOOL str_is_all(const char *s,char c)
|
|||||||
{
|
{
|
||||||
while (*s)
|
while (*s)
|
||||||
{
|
{
|
||||||
size_t skip = skip_multibyte_char( *s );
|
size_t skip = get_character_len( *s );
|
||||||
if( skip != 0 )
|
if( skip != 0 )
|
||||||
s += skip;
|
s += skip;
|
||||||
else {
|
else {
|
||||||
|
@ -54,7 +54,7 @@ int dos_PutUniCode(char *dst,const char *src, ssize_t len)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
while (*src && (len > 2)) {
|
while (*src && (len > 2)) {
|
||||||
size_t skip = skip_multibyte_char(*src);
|
size_t skip = get_character_len(*src);
|
||||||
smb_ucs2_t val = (*src & 0xff);
|
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) {
|
if (src != NULL) {
|
||||||
for (; *src && len < max_len-2; len++, dst +=2) {
|
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);
|
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. */
|
dst_len /= sizeof(smb_ucs2_t); /* Convert to smb_ucs2_t units. */
|
||||||
|
|
||||||
for(i = 0; (i < (dst_len - 1)) && src[i];) {
|
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);
|
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. */
|
/* we should recognize if `\` is part of a multibyte character or not. */
|
||||||
while(pos2 <= pos) {
|
while(pos2 <= pos) {
|
||||||
size_t skip = 0;
|
size_t skip = 0;
|
||||||
skip = skip_multibyte_char(line[pos2]);
|
skip = get_character_len(line[pos2]);
|
||||||
if (skip) {
|
if (skip) {
|
||||||
pos2 += skip;
|
pos2 += skip;
|
||||||
} else if (pos == pos2) {
|
} else if (pos == pos2) {
|
||||||
|
@ -255,7 +255,7 @@ static BOOL is_illegal_name( char *name )
|
|||||||
s = (unsigned char *)name;
|
s = (unsigned char *)name;
|
||||||
while( *s )
|
while( *s )
|
||||||
{
|
{
|
||||||
skip = skip_multibyte_char( *s );
|
skip = get_character_len( *s );
|
||||||
if( skip != 0 )
|
if( skip != 0 )
|
||||||
{
|
{
|
||||||
s += skip;
|
s += skip;
|
||||||
@ -374,7 +374,7 @@ BOOL is_8_3( char *fname, BOOL check_case )
|
|||||||
dot_pos = NULL;
|
dot_pos = NULL;
|
||||||
while( *p )
|
while( *p )
|
||||||
{
|
{
|
||||||
if( (skip = skip_multibyte_char( *p )) != 0 )
|
if( (skip = get_character_len( *p )) != 0 )
|
||||||
p += skip;
|
p += skip;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -878,7 +878,7 @@ void mangle_name_83( char *s)
|
|||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
while( *p && extlen < 3 )
|
while( *p && extlen < 3 )
|
||||||
{
|
{
|
||||||
skip = skip_multibyte_char( *p );
|
skip = get_character_len( *p );
|
||||||
switch( skip )
|
switch( skip )
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
@ -912,7 +912,7 @@ void mangle_name_83( char *s)
|
|||||||
|
|
||||||
while( *p && baselen < 5 )
|
while( *p && baselen < 5 )
|
||||||
{
|
{
|
||||||
skip = skip_multibyte_char(*p);
|
skip = get_character_len(*p);
|
||||||
switch( skip )
|
switch( skip )
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -1334,7 +1334,7 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
|||||||
p = mask;
|
p = mask;
|
||||||
while(*p)
|
while(*p)
|
||||||
{
|
{
|
||||||
if((skip = skip_multibyte_char( *p )) != 0 )
|
if((skip = get_character_len( *p )) != 0 )
|
||||||
{
|
{
|
||||||
p += skip;
|
p += skip;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user