Thanks for the pointers Mike. I'll take a dump and see what I get. :-) I've debated using the #. I guess that's more universal as it will call a length metamethod if it exists. I've converted to the int array, and use the cast. I have yet to test on an extremely large data set, but it just feels cleaner, meaner, and morally correct. -- William =============================== - Shaping clay is easier than digging it out of the ground. http://williamaadams.wordpress.com http://www.thingiverse.com/WilliamAAdams https://github.com/Wiladams ---------------------------------------- > Date: Wed, 30 May 2012 15:15:31 +0200 > From: mike-1205@xxxxxxxxxx > To: luajit@xxxxxxxxxxxxx > Subject: Re: calculating CRC > > William Adams wrote: > > 1) Would I be better off doing a cast of 's' in the beginning, > > and then using simple array access after that? Any great > > advantage over just doing the getbytes? My assumption is it > > would be faster, but I don't know of other tradeoffs. > > It should be slightly faster. Not all range checks can be > eliminated for string.byte(). > > > 2) Should I switch the Digest.consts table to being an array of > > in32_t instead of a Lua table? Will it be more efficient in > > some way, or some other benefit? > > It avoids bounds checks, type checks and plenty of double -> int > conversions (in single-number mode, default on x86/x64). So yes, > it would make a difference. > > BTW: string.len(s) is compatibility from Lua 5.0. Better use #s. > > BTW#2: Try -jdump on a sample snippet only testing this code. Even > if you don't know much about assembler, you can still judge the > length of the machine code inside the 'LOOP'. Shorter is better, > less branches and less loads/stores are better. Beware: it's > addictive to stare at compiler output. :-) > > --Mike >