charConv: optimize away a boatload of strdups during update (try #2)

This was originally introduced in r3718, but reverted r3859 since the
original r3718 commit was incorrect (and I was too excited about
the speedup and also lacking in UTF-8 files to notice :x)

git-svn-id: https://svn.musicpd.org/mpd/trunk@4517 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Eric Wong 2006-08-01 12:02:47 +00:00
parent 468c9900ca
commit 83b619e997

View File

@ -45,10 +45,19 @@ static void closeCharSetConversion();
int setCharSetConversion(char *to, char *from)
{
if (char_conv_to && char_conv_from &&
strcmp(to, char_conv_to) == 0 && strcmp(from, char_conv_from) == 0)
{
return 0;
if (char_conv_to && char_conv_from) {
if (char_conv_latin1ToUtf8 &&
!strcmp(from, char_conv_to) &&
!strcmp(to, char_conv_from)) {
char *swap = char_conv_from;
char_conv_from = char_conv_to;
char_conv_to = swap;
char_conv_latin1ToUtf8 *= -1;
return 0;
} else if (!strcmp(to, char_conv_to) &&
!strcmp(from,char_conv_from)) {
return 0;
}
}
closeCharSetConversion();