mirror of
git://git.musl-libc.org/musl
synced 2025-03-05 03:07:29 +00:00
remove invalid skip of locking in ungetwc
aside from being invalid, the early check only optimized the error case, and likely pessimized the common case by separating the two branches on isascii(c) at opposite ends of the function.
This commit is contained in:
parent
63f4b9f18f
commit
7e816a6487
@ -11,18 +11,15 @@ wint_t ungetwc(wint_t c, FILE *f)
|
||||
|
||||
if (c == WEOF) return c;
|
||||
|
||||
/* Try conversion early so we can fail without locking if invalid */
|
||||
if (!isascii(c) && (l = wctomb((void *)mbc, c)) < 0)
|
||||
return WEOF;
|
||||
|
||||
FLOCK(f);
|
||||
|
||||
f->mode |= f->mode+1;
|
||||
|
||||
if (!f->rpos) __toread(f);
|
||||
if (!f->rpos || f->rpos < f->buf - UNGET + l) {
|
||||
if (!f->rpos || f->rpos < f->buf - UNGET + l ||
|
||||
(!isascii(c) && (l = wctomb((void *)mbc, c)) < 0)) {
|
||||
FUNLOCK(f);
|
||||
return EOF;
|
||||
return WEOF;
|
||||
}
|
||||
|
||||
if (isascii(c)) *--f->rpos = c;
|
||||
|
Loading…
Reference in New Issue
Block a user