cpplib: optimize number parsing

H . J . Lu hjl@lucon.org
Mon May 27 21:32:00 GMT 2002


On Mon, May 27, 2002 at 11:12:28PM +0100, Neil Booth wrote:
> This patch optimizes number parsing.  First, we special case
> single digit numbers.  I'd guesstimate this accounts for at least
> 30% of pp-numbers.  Second, we don't do two-integer arithmetic
> to value a number until that amount of precision is needed.
> >From an eye-scan of a lot of files I have lying around, I'd
> guess these two account for way over 90% of all pp numbers,
> so this effectively means that our double-integer handling
> has minimal cost for number interpretation at least.
> 
> The first is also done by the front-end in c-lex.c.  c-lex.c would
> benefit a lot from the second too; maybe you could consider keeping
> it if you ever dust off your numbers patch, Zack.  In fact, since I
> moved to using unsigned HOST_WIDE_INT for the CPP half-integer, there
> are no obstacles to integrating the two number parsers like Zack's
> patch originally attempted.  I may get round to doing that myself
> if you're too busy, Zack.
> 
> Bootstrapped x86 Linux.  This also contains a more correct
> version of HJ's patch where we cast to cpp_num_part instead
> of using UL, as it may be unsigned long long.
> 

I will bootstrap mainline on alpha after you check in this change.



H.J.



More information about the Gcc-patches mailing list