On Sun, Dec 17, 2000 at 11:27:32AM -0600, Jarkko Hietaniemi wrote: > On Sun, Dec 17, 2000 at 04:29:24PM +0000, Nicholas Clark wrote: > > Why do all the XS constant() routines (that I've looked at) have a second > > unused integer argument after the name argument? > > I assume that they return double because perl did all arithmetic (except > > logical operations such as |) as doubles > > I think pretty much all the Perl XS extensions have started their life > as h2xs outputs, even if they have been mucked around by hand quite > extensively since then -- and h2xs still has these lines: > > print $fh <<"END"; > static double > constant(char *name, int len, int arg) > { > errno = 0; > > Not even NV, "double". Sigh. But the "int len" for the string's length *is* a nifty idea. So the guilding the lilly department presents a revised Fcntl.xs that is faster (when you measure it over a 1,000,000 loop) *and* smaller. Not that this really makes any noticeable difference to the regression tests. :-) But it's the thought of it being faster that counts. Before text data bss dec hex filename 5944 0 0 5944 1738 ext/Fcntl/Fcntl.o All tests successful. u=1.77 s=0.47 cu=71.86 cs=10.67 scripts=270 tests=20850 real 2m20.023s user 1m13.630s sys 0m11.140s After text data bss dec hex filename 5512 0 0 5512 1588 ext/Fcntl/Fcntl.o All tests successful. u=1.65 s=0.47 cu=71.12 cs=11.93 scripts=270 tests=20850 real 2m15.466s user 1m12.770s sys 0m12.400s (and I get more variation in those timings than the difference between them. Benchmarking the constant code shows it to be slightly faster) not-a-patch because the patch would be longer than the file. You don't have to use this if you don't feel the need. Nicholas ClarkThread Previous | Thread Next