Einzelnen Beitrag anzeigen

Kas Ob.

Registriert seit: 3. Sep 2023
365 Beiträge
 
#19

AW: Kleines Weihnachtsgeschenk von der DEC

  Alt 3. Jan 2025, 08:01
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 ...
Simple, none of these can be negative but all can be zero, with only one condition that MinLength and BlockSize can't be zero at the same time.
Kas
  Mit Zitat antworten Zitat