提交 a49e038b 编写于 作者: R Rich Felker

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.
上级 8f06ab0e
...@@ -22,9 +22,8 @@ size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t n, mbstate ...@@ -22,9 +22,8 @@ size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t n, mbstate
c = *(unsigned *)st; c = *(unsigned *)st;
if (!s) { if (!s) {
s = (void *)""; if (c) goto ilseq;
wc = (void *)&wc; return 0;
n = 1;
} else if (!wc) wc = (void *)&wc; } else if (!wc) wc = (void *)&wc;
if (!n) return -2; if (!n) return -2;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册