BitAnd
a different way to alternate
Categories: ColdFusion
We've all found a billion ways to achieve some kind of alternating event in our websites,
whether it's alternating row colors, content or a myriad of other things..
In the ColdFusion world we use the CF Mod() function alot.. but did you know how much overhead it actually creates? For each iteration it must divide the numbers in question and look at the remainder. Based on that remainder the Mod is either odd or even...
but..
I stumbled on to a better way, ColdFusion has a function called BitAnd(), instead of dividing numbers
this works at the bit level and it's substantially faster:
Ben Nadel does a great overview here: http://www.bennadel.com/blog/668-Using-BitAnd-To-Determine-Odd-Even-Rows-Thanks-Tony-Petruzzi-.htm.
I've found a significant performance increase, especially with large data outputs needing alternating something..
Posted by admin at 10:18 AM | Link | 0 comments
Comments
No comments found.
Commenting has been disabled for this entry.