diff options
author | Bruno Haible <bruno@clisp.org> | 2011-02-21 05:07:14 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2011-02-21 05:07:14 +0100 |
commit | b16127c6a3a05b948c92869dd28905472706583f (patch) | |
tree | 902e13ce773ab7fa92322b652a21c3c15c50983b | |
parent | 52357e723c251f4a4d8d5ce93790d7c88885cde6 (diff) | |
download | gnulib-b16127c6a3a05b948c92869dd28905472706583f.tar.gz |
mbrtowc: Tiny optimization.
* lib/mbrtowc.c (mbrtowc): Delay pstate assignment until it is needed.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/mbrtowc.c | 7 |
2 files changed, 9 insertions, 3 deletions
@@ -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]; |