Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

(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.

--Chris

e-mail jcwren


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-12-26 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls