From dee2b958c0412296e7944a120d28dd0a350f0223 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Mar 2015 15:03:47 +0000 Subject: [PATCH] lib: Move get_iconv_handle() call down We only need this in the slow path. A good compiler might detect this, but as get_iconv_handle() might have side-effects from a compiler's point of view, I'm not sure it's legal to skip the call in the fast path. Might be premature optimization, but it's low hanging fruit :-) Signed-off-by: Volker Lendecke Reviewed by: Ira Cooper Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Mon Mar 23 21:21:15 CET 2015 on sn-devel-104 --- lib/util/charset/util_str.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/util/charset/util_str.c b/lib/util/charset/util_str.c index d2e6cbbc620..1cbc1cd9652 100644 --- a/lib/util/charset/util_str.c +++ b/lib/util/charset/util_str.c @@ -369,7 +369,7 @@ _PUBLIC_ char *strchr_m(const char *src, char c) */ _PUBLIC_ char *strrchr_m(const char *s, char c) { - struct smb_iconv_handle *ic = get_iconv_handle(); + struct smb_iconv_handle *ic; char *ret = NULL; if (s == NULL) { @@ -416,6 +416,8 @@ _PUBLIC_ char *strrchr_m(const char *s, char c) return NULL; } + ic = get_iconv_handle(); + while (*s) { size_t size; codepoint_t c2 = next_codepoint_handle(ic, s, &size); -- 2.11.4.GIT