Performance trick: optimistic vs. pessimistic checks (opens in new tab)
Strings in programming are often represented as arrays of 8-bit words. The string is ASCII if and only if all 8-bit words have their most significant bit unset. In other words, the byte values must be no larger than 127 (or 0x7F in hexadecimal). A decent C function to check that the string is ASCII … Continue reading Performance trick : optimistic vs pessimistic checks
Read the original article