Einzelnen Beitrag anzeigen

Rollo62

Registriert seit: 15. Mär 2007
4.126 Beiträge
 
Delphi 12 Athens
 
#16

AW: Kleines Weihnachtsgeschenk von der DEC

  Alt 2. Jan 2025, 18:10
TL;DR;

What just jump into my eye is this, cant this be written more efficient?
Delphi-Quellcode:
class function TDECPaddingCommon.CalculatePaddingLength(DataLength, BlockSize, MinLength: Integer): Integer;
begin
  if (MinLength < 0) or (DataLength < 0) or (BlockSize < 0) or (MinLength or BlockSize = 0) then
  begin
  ...
like so

Delphi-Quellcode:
class function TDECPaddingCommon.CalculatePaddingLength(DataLength, BlockSize, MinLength: Integer): Integer;
begin
  if (MinLength <= 0) or (DataLength <= 0) or (BlockSize <= 0) then
  begin
  ...
Not sure is there is any hidden math trick behind that logic, have not thought too deep into it ...
  Mit Zitat antworten Zitat