towards a faster isdigit()
Henry Spencer
henry at zoo.toronto.edu
Thu May 9 03:18:38 AEST 1991
In article <716 at taumet.com> steve at taumet.com (Stephen Clamage) writes:
>> #define isdigit(c) ((unsigned)((c)-'0') < 10)
>
>The macro you suggest requires a test and jump, and on some modern RISC
>machines the penalty is very high...
No, it requires a test and convert-test-value-to-data operation, which
on some RISC machines does not require a jump. (I'll avoid putting in
a plug for my favorite one... :-)) Besides, the main use for predicates
like this is in driving conditional jumps, so in fact the conversion
is rarely needed and there is no added jump.
--
And the bean-counter replied, | Henry Spencer @ U of Toronto Zoology
"beans are more important". | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list