bug in gmp_fprintf?

Niels Möller nisse at lysator.liu.se
Tue Nov 24 06:15:19 UTC 2015

tg at gmplib.org (Torbjörn Granlund) writes:

> In reproducing the error, I ran into embarrassingly slow code in
> scanf/doscan.c; we read a byte at a time through a callback (see GET())
> and test the base argument in a tight, serially dependent loop.

The first thing to do when optimizing anything using (f)getc, is to use
getc_unlocked (and flockfile/funlockfile outside of the loop).

Maybe that's enoough to get reasonable speed?

>       while (...)
>         ungetc(bp[...], fp);

I'm suspect it's unportable to ungetc more than one character.


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-bugs mailing list