Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

(jcwren) Re: Re: The Ovidian Transform

by jcwren (Prior)
on Jan 01, 2002 at 00:05 UTC ( #135421=note: print w/ replies, xml ) Need Help??

in reply to Re: The Ovidian Transform
in thread The Ovidian Transform

While the lack of error checking would certainly be foolish, you can micro-optimize this even more.

The while() loop isn't smart enough to compile down to a 'scasb' instruction, whereas if you use 'memchr', the compiler is smart enough to play some games with it. While I haven't checked the code strncpy() uses, I know for a fact that memcpy() will reduce to either a 'rep movsb' sequence, or more likely for only 8 bytes, 2 loads and 2 stores (4 instructions). If you're on an Alpha, it'll be 2 instructions, a single load and a single store.

strncpy() is portable and is good in that respect. memcpy() is less so, since it presumes certain things about the processor architecture.

/me is glad to see Ovid start hacking Inline::C. It's a lot of fun. Perl is good, but not always perfect. Perl combined with Inline::C can let you do some truly scarey things.


e-mail jcwren

Comment on (jcwren) Re: Re: The Ovidian Transform

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://135421]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2015-11-27 04:33 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (718 votes), past polls