2 ms·
Most string libs aren't that smart though - string comparisons are still byte by byte. You're now comparing something 15 times instead of 1. You can do an int32
by potatolicious 17y ago
Most string libs aren't that smart though - string comparisons are still byte by byte. You're now comparing something 15 times instead of 1. You can do an int32/int64 (depending on architecture) compare in a single op.
The point I guess is, you can keep 'em around as charstars, but eventually you'll have to do this cast to compare them...
- tptacek 17y agoAll memcmp's are this smart. But that's kind of besides the point, right? 1 time, 14 times, if we're talking about L1 cache, we're really epsilon from pure reg/reg ALU operations, implementing effectively constant-time algorithms. I agree, int32 is faster. Like I said, it's just not "much" faster.