Spelt / ZXing.Delphi

ZXing Barcode Scanning object Pascal Library for Delphi VCL and Delphi Firemonkey
Apache License 2.0
471 stars 206 forks source link

Useless assignment? #82

Closed csm101 closed 5 years ago

csm101 commented 5 years ago

Hi, I just noticed this strange assignment within ZXing.QrCode.Internal.FinderPatternImplementation.pas:

function TFinderPattern.aboutEquals(const moduleSize, i, j: Single): Boolean;
var
  moduleSizeDiff : Single;
begin
  Result := false;

  x := Self.x; //  <-- Why are we doing this?
  y := Self.y; //  <-- Why are we doing this?

  if ((Abs(i - self.y) <= moduleSize) and (Abs(j - self.x) <= moduleSize)) then
  begin
    moduleSizeDiff := Abs(moduleSize - self.estimatedModuleSize);

    Result := ((moduleSizeDiff <= 1) or
       (moduleSizeDiff <= self.estimatedModuleSize));
  end;
end;

It looks like we are assigning self.x and self.y to themselves. Do those two lines actually do something useful?

Spelt commented 5 years ago

Your'e right. It does nothing at all. I cleaned it up.

Thanks Carlo!

Op ma 18 feb. 2019 om 16:35 schreef Carlo Sirna notifications@github.com:

Hi, I just noticed this strange assignment within ZXing.QrCode.Internal.FinderPatternImplementation.pas:

function TFinderPattern.aboutEquals(const moduleSize, i, j: Single): Boolean; var moduleSizeDiff : Single; begin Result := false;

x := Self.x; // <-- Why are we doing this? y := Self.y; // <-- Why are we doing this?

if ((Abs(i - self.y) <= moduleSize) and (Abs(j - self.x) <= moduleSize)) then begin moduleSizeDiff := Abs(moduleSize - self.estimatedModuleSize);

Result := ((moduleSizeDiff <= 1) or
   (moduleSizeDiff <= self.estimatedModuleSize));

end; end;

It looks like we are assigning self.x and self.y to themselves. Do those two lines actually do something useful?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Spelt/ZXing.Delphi/issues/82, or mute the thread https://github.com/notifications/unsubscribe-auth/AMEt1QDO2X3c5HWDcYSBMDGUD_vIKAkRks5vOshbgaJpZM4bBHvg .