summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-02-21 05:07:14 +0100
committerBruno Haible <bruno@clisp.org>2011-02-21 05:07:14 +0100
commitb16127c6a3a05b948c92869dd28905472706583f (patch)
tree902e13ce773ab7fa92322b652a21c3c15c50983b
parent52357e723c251f4a4d8d5ce93790d7c88885cde6 (diff)
downloadgnulib-b16127c6a3a05b948c92869dd28905472706583f.tar.gz
mbrtowc: Tiny optimization.
* lib/mbrtowc.c (mbrtowc): Delay pstate assignment until it is needed.
-rw-r--r--ChangeLog5
-rw-r--r--lib/mbrtowc.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 289730afdc..dbdc5303b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-20 Bruno Haible <bruno@clisp.org>
+
+ mbrtowc: Tiny optimization.
+ * lib/mbrtowc.c (mbrtowc): Delay pstate assignment until it is needed.
+
2011-02-20 Jim Meyering <meyering@redhat.com>
test-exclude.c: remove unmatched #endif
diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c
index 0546f6db7a..d9c25cced6 100644
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -40,9 +40,6 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
char *pstate = (char *)ps;
- if (pstate == NULL)
- pstate = internal_state;
-
if (s == NULL)
{
pwc = NULL;
@@ -54,6 +51,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
return (size_t)(-2);
/* Here n > 0. */
+
+ if (pstate == NULL)
+ pstate = internal_state;
+
{
size_t nstate = pstate[0];
char buf[4];