Julian,
In C++ I remember a switch compiles to a single integer compare+jump call,
and although Java is P-Code i think it does a similar thing. The optimizer
in Java may be smart enough to convert a bunch of "||" calls to a switch
when possible, so you are right that compiler *smarts* is a factor here.

Best regards,
Clay Ferguson
[email protected]


On Thu, Dec 22, 2016 at 1:00 AM, Julian Reschke <[email protected]>
wrote:

> On 2016-12-22 01:49, Clay Ferguson wrote:
>
>> BTW: This code would execute 10x faster as a switch statement:
>>
>> if (c == '!' || c == '(' || c == ':' || c == '^'
>>             || c == '[' || c == ']' || c == '{' || c == '}' || c == '?'
>> || c == '\\') {
>>             sb.append('\\');
>>         }
>>
>
> Would it?
>
> (Stupid compiler, I'd say...)
>
>

Reply via email to