From 83b619e997c5ab9d0eb57a365b59f34a9607c3a3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 1 Aug 2006 12:02:47 +0000 Subject: 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 --- src/charConv.c | 17 +++++++++++++---- 1 file 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(); -- cgit v1.2.3