Make stderr go faster

This change makes _IONBF (unbuffered) stdio handles go 20x faster for
certain kinds of formatting directives by being smarter about buffers
This commit is contained in:
Justine Tunney 2023-08-11 11:56:35 -07:00
parent 2cbd09b4d4
commit 8fc778162e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
6 changed files with 70 additions and 38 deletions

View file

@ -244,15 +244,15 @@ static int __fmt_ntoa2(int out(const char *, void *, size_t), void *arg,
unsigned len, count, digit;
char buf[BUFFER_SIZE];
len = 0;
/* we check for log2base != 3 because otherwise we'll print nothing for a
* value of 0 with precision 0 when # mandates that one be printed */
// we check for log2base!=3, since otherwise we'll print nothing for
// a value of 0 with precision 0 when # mandates that one be printed
if (!value && log2base != 3) flags &= ~FLAGS_HASH;
if (value || !(flags & FLAGS_PRECISION)) {
count = 0;
do {
if (!log2base) {
if (value <= UINT64_MAX) {
value = DivMod10(value, &digit);
value = __divmod10(value, &digit);
} else {
value = __udivmodti4(value, 10, &remainder);
digit = remainder;