瀏覽代碼

* 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 -

marco 4 年之前
父節點
當前提交
f26c366e9b
共有 1 個文件被更改,包括 2 次插入9 次删除
  1. 2 9
      packages/fcl-image/src/fpreadbmp.pp

+ 2 - 9
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;