From 3dcea500739354ff4755dc5c6dc08cab775ec3dd Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 8 Nov 2006 15:29:14 +0000 Subject: [PATCH] Remove some unneeded iconv calls (for UTF-8 term) --- src/common/util.c | 14 +++++++++++++- weechat/src/common/util.c | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/common/util.c b/src/common/util.c index aea6b03ea..96ebc835b 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -269,8 +269,14 @@ char * weechat_iconv_to_internal (char *charset, char *string) { char *input, *output; - + input = strdup (string); + + /* optimize for UTF-8: if charset is NULL => we use term charset => + if ths charset is already UTF-8, then no iconv needed */ + if (local_utf8 && (!charset || !charset[0])) + return input; + if (input) { if (utf8_is_valid (input, NULL)) @@ -298,6 +304,12 @@ weechat_iconv_from_internal (char *charset, char *string) char *input, *output; input = strdup (string); + + /* optimize for UTF-8: if charset is NULL => we use term charset => + if ths charset is already UTF-8, then no iconv needed */ + if (local_utf8 && (!charset || !charset[0])) + return input; + if (input) { utf8_normalize (input, '?'); diff --git a/weechat/src/common/util.c b/weechat/src/common/util.c index aea6b03ea..96ebc835b 100644 --- a/weechat/src/common/util.c +++ b/weechat/src/common/util.c @@ -269,8 +269,14 @@ char * weechat_iconv_to_internal (char *charset, char *string) { char *input, *output; - + input = strdup (string); + + /* optimize for UTF-8: if charset is NULL => we use term charset => + if ths charset is already UTF-8, then no iconv needed */ + if (local_utf8 && (!charset || !charset[0])) + return input; + if (input) { if (utf8_is_valid (input, NULL)) @@ -298,6 +304,12 @@ weechat_iconv_from_internal (char *charset, char *string) char *input, *output; input = strdup (string); + + /* optimize for UTF-8: if charset is NULL => we use term charset => + if ths charset is already UTF-8, then no iconv needed */ + if (local_utf8 && (!charset || !charset[0])) + return input; + if (input) { utf8_normalize (input, '?');