[fpc-pascal] Can FPC optimize: if (s[i]='a') or ...

Ralf Quint freedos.la at gmail.com
Sat Apr 13 21:55:45 CEST 2019


On 4/13/2019 12:30 PM, Alexey Tor. wrote:
> E.g. i have a loop which test each s[i] char for several cases: 'a', 
> 'b', 'c'.
>
> for i:= 1 to length(s) do
>
> if (s[i]='a') or (s[i]='b') or (s[i]='c') then ...
>
> Can FPC optimize it so it only reads s[i] once (to register), not 3 
> times?
>
How about writing it in Pascal, something like

if s[i] in ['a'..'c'] then

or in case of no-sequential characters/values

if s[i] in ['a', 'b', 'c'] then...


Ralf


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus




More information about the fpc-pascal mailing list