mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 16:59:11 +02:00
* use popcnt instead of countbits.
* change countbits to popcnt in case it is used by others. suggestion by Bi0t1n, mantis 0038728 git-svn-id: trunk@49161 -
This commit is contained in:
parent
ff3f812d97
commit
f26c366e9b
@ -124,15 +124,8 @@ end;
|
|||||||
|
|
||||||
{ Counts how many bits are set }
|
{ Counts how many bits are set }
|
||||||
function TFPReaderBMP.CountBits(Value : byte) : shortint;
|
function TFPReaderBMP.CountBits(Value : byte) : shortint;
|
||||||
var i,bits : shortint;
|
|
||||||
begin
|
begin
|
||||||
bits:=0;
|
Result:=PopCnt(Value);
|
||||||
for i:=0 to 7 do
|
|
||||||
begin
|
|
||||||
if (value mod 2)<>0 then inc(bits);
|
|
||||||
value:=value shr 1;
|
|
||||||
end;
|
|
||||||
Result:=bits;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ If compression is bi_bitfields, there could be arbitrary masks for colors.
|
{ If compression is bi_bitfields, there could be arbitrary masks for colors.
|
||||||
@ -156,7 +149,7 @@ begin
|
|||||||
inc(tmp);
|
inc(tmp);
|
||||||
Mask:= Mask shr 1;
|
Mask:= Mask shr 1;
|
||||||
end;
|
end;
|
||||||
tmp:=tmp-(8-CountBits(Mask and $FF));
|
tmp:=tmp-(8-popcnt(Mask and $FF));
|
||||||
Result:=tmp;
|
Result:=tmp;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user