[PATCH] lib: Move get_iconv_handle() call down
Volker Lendecke
Volker.Lendecke at SerNet.DE
Mon Mar 23 09:07:58 MDT 2015
Hi!
Review&push appreciated!
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 72837b574b7d1283abee0fd88f8cb449b000a264 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
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 <vl at samba.org>
---
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 d2e6cbb..1cbc1cd 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);
--
1.7.9.5
More information about the samba-technical
mailing list