diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-08-01 12:02:47 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-08-01 12:02:47 +0000 |
commit | 83b619e997c5ab9d0eb57a365b59f34a9607c3a3 (patch) | |
tree | 3916f32e615c808e3c3eb0a4822973ae3c6b3e2e /src | |
parent | 468c9900cae45378d6ef4d5709dcf57be8e9fa0d (diff) | |
download | mpd-83b619e997c5ab9d0eb57a365b59f34a9607c3a3.tar.gz mpd-83b619e997c5ab9d0eb57a365b59f34a9607c3a3.tar.xz mpd-83b619e997c5ab9d0eb57a365b59f34a9607c3a3.zip |
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
Diffstat (limited to '')
-rw-r--r-- | src/charConv.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/charConv.c b/src/charConv.c index 05c03167e..4e4aa864a 100644 --- a/src/charConv.c +++ b/src/charConv.c @@ -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(); |