Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
I generally use the modulo operator too... But in situations where absolute performance is required i might compare the counter with the number, and if they're even, reset the counter to 0...
timvw wrote:But in situations where absolute performance is required i might compare the counter with the number, and if they're even, reset the counter to 0...
Look, in the end, the database/file-system calls are going to weigh a lot more than a modulus operator called fifty times for a nicely colored table. Just use whatever is most readable and comfortable for you.
Ambush Commander wrote:Look, in the end, the database/file-system calls are going to weigh a lot more than a modulus operator called fifty times for a nicely colored table. Just use whatever is most readable and comfortable for you.
I have no doubt that the bottleneck would not be in the row coloring, I asked if the boolean would be faster simply for my own knowledge's sake....I don't know and want to know.
Sorry, I wasn't trying to directly knock you, I was trying to discuss the thread as a whole.
But while we're on a theoretical basis: no, because once you incremented the variable, it would have to be cast back into an integer. Edit Wait, I think I'm misunderstanding you. What do you mean by using a boolean?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
timvw wrote:But in situations where absolute performance is required i might compare the counter with the number, and if they're even, reset the counter to 0...
wouldn't a boolean be faster than that?
Likely yes. The modulus operator takes two numbers and divides them, returning the remainder...
Anything division on a CPU even with a dedicated FPU is a slow(er) process than whole number calculations. Boolean at the lowest level is typically an integer, so yes, in theory it would be faster.