diff options
author | Rich Felker <dalias@aerifal.cx> | 2013-04-08 22:49:59 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2013-04-08 22:49:59 -0400 |
commit | a49e038bab7b3927b6a9c7d0c52f9e1a9cb82629 (patch) | |
tree | 4d4f8a1686d8db7588efed0d7f03968e76d5294e /src | |
parent | 8f06ab0eb9c22998a47803938588bb0b13092a0b (diff) | |
download | musl-a49e038bab7b3927b6a9c7d0c52f9e1a9cb82629.tar.gz |
optimize mbrtowc
this simple change, in my measurements, makes about a 7% performance
improvement. at first glance this change would seem like a
compiler-specific hack, since the modified code is not even used.
however, I suspect the reason is that I'm eliminating a second path
into the main body of the code, allowing the compiler more flexibility
to optimize the normal (hot) path into the main body. so even if it
weren't for the measurable (and quite notable) difference in
performance, I think the change makes sense.
Diffstat (limited to 'src')
-rw-r--r-- | src/multibyte/mbrtowc.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/multibyte/mbrtowc.c b/src/multibyte/mbrtowc.c index cc497810..ec323859 100644 --- a/src/multibyte/mbrtowc.c +++ b/src/multibyte/mbrtowc.c @@ -22,9 +22,8 @@ size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t n, mbstate c = *(unsigned *)st; if (!s) { - s = (void *)""; - wc = (void *)&wc; - n = 1; + if (c) goto ilseq; + return 0; } else if (!wc) wc = (void *)&wc; if (!n) return -2; |