diff options
author | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-10 10:56:47 +0000 |
---|---|---|
committer | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-10 10:56:47 +0000 |
commit | 67099310f0a01254cfdd0316e46e94155af32f9f (patch) | |
tree | 8c0cc800933d0168b59c115b94ea7e4125e6383e | |
parent | 22f28adf30c02acc719b905fd005e95c6305967b (diff) | |
download | fpc-67099310f0a01254cfdd0316e46e94155af32f9f.tar.gz |
* use popcnt instead of countbits.
* change countbits to popcnt in case it is used by others.
suggestion by Bi0t1n, mantis 0038728
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49161 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | packages/fcl-image/src/fpreadbmp.pp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/packages/fcl-image/src/fpreadbmp.pp b/packages/fcl-image/src/fpreadbmp.pp index 65ac9c3a8a..f566af28d5 100644 --- a/packages/fcl-image/src/fpreadbmp.pp +++ b/packages/fcl-image/src/fpreadbmp.pp @@ -124,15 +124,8 @@ end; { Counts how many bits are set } function TFPReaderBMP.CountBits(Value : byte) : shortint; -var i,bits : shortint; begin - bits:=0; - for i:=0 to 7 do - begin - if (value mod 2)<>0 then inc(bits); - value:=value shr 1; - end; - Result:=bits; + Result:=PopCnt(Value); end; { If compression is bi_bitfields, there could be arbitrary masks for colors. @@ -156,7 +149,7 @@ begin inc(tmp); Mask:= Mask shr 1; end; - tmp:=tmp-(8-CountBits(Mask and $FF)); + tmp:=tmp-(8-popcnt(Mask and $FF)); Result:=tmp; end; |