|
|
|
|
|
by jeffbee
990 days ago
|
|
What about something like https://github.com/abseil/abseil-cpp/blob/master/absl/string... ? ASCII lowercase can be something like auto is_upper= (x > '@') & (x < '[');
return is_upper ? x+32 : x;
Which boils down to add, add, cmp, cmov on x86. It might save some cache traffic, but the cache traffic is less code since it's only a mov. The version that's code instead of lookups probably exacerbates register pressure problems in large programs? I don't have good intuition for which would be more efficient in practice. |
|
I dunno, it's ridiculously a benefit to the code by my instinct. While lookup table looks pretty bad.