Optimization at function TFPReaderBMP.ShiftCount
from 'lagprogramming'. packages/fcl-image/src/fpreadbmp.pp has ```pascal function TFPReaderBMP.ShiftCount(Mask : longword) : shortint; var tmp : shortint; begin tmp:=0; if Mask=0 then begin Result:=0; exit; end; while (Mask mod 2)=0 do { rightmost bit is 0 } begin inc(tmp); Mask:= Mask shr 1; end; tmp:=tmp-(8-popcnt(byte(Mask and $FF))); Result:=tmp; end; ``` The following patch replaces "while (Mask mod 2)=0 do" with the faster "while (Mask and 1)=0 do" line. [patch.diff](/uploads/77918f8f8e6a89a63c7b87948107cfe5/patch.diff) Another forum user: >Addition: 1) Line 16+17 can be coalesced into one line 2) Why use a tmp-var in the first place? Forum user 'RayoGlauco': >My own version may be like this ```pascal function TFPReaderBMP.ShiftCount(Mask : longword) : shortint; begin Result:=0; if Mask=0 then exit; while (Mask and 1)=0 do { rightmost bit is 0 } begin inc(Result); Mask:= Mask shr 1; end; Result:= Result-(8-popcnt(byte(Mask and $FF))); end; ```
issue