mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
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:
parent
2cbd09b4d4
commit
8fc778162e
6 changed files with 70 additions and 38 deletions
|
@ -2,23 +2,23 @@
|
|||
#define COSMOPOLITAN_LIBC_FMT_DIVMOD10_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
forceinline uint64_t DivMod10(uint64_t x, unsigned *r) {
|
||||
forceinline uint64_t __divmod10(uint64_t __x, unsigned *__r) {
|
||||
#if defined(__STRICT_ANSI__) || !defined(__GNUC__) || \
|
||||
(defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__))
|
||||
*r = x % 10;
|
||||
return x / 10;
|
||||
*__r = __x % 10;
|
||||
return __x / 10;
|
||||
#else
|
||||
uint128_t dw;
|
||||
unsigned long long hi, rm;
|
||||
dw = x;
|
||||
dw *= 0xcccccccccccccccdull;
|
||||
hi = dw >> 64;
|
||||
hi >>= 3;
|
||||
rm = hi;
|
||||
rm += rm << 2;
|
||||
rm += rm;
|
||||
*r = x - rm;
|
||||
return hi;
|
||||
uint128_t __dw;
|
||||
unsigned long long __hi, __rm;
|
||||
__dw = __x;
|
||||
__dw *= 0xcccccccccccccccdull;
|
||||
__hi = __dw >> 64;
|
||||
__hi >>= 3;
|
||||
__rm = __hi;
|
||||
__rm += __rm << 2;
|
||||
__rm += __rm;
|
||||
*__r = __x - __rm;
|
||||
return __hi;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue