Browse Source

* patch by Rika: SwapEndian([u]int16) has unnecessary “and $FFFF”, resolves #39814

florian 3 years ago
parent
commit
f92102a5f2
1 changed files with 2 additions and 2 deletions
  1. 2 2
      rtl/inc/generic.inc

+ 2 - 2
rtl/inc/generic.inc

@@ -2667,13 +2667,13 @@ function SwapEndian(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inlin
     { is turned into "longint(AValue) shr 8", so if AValue < 0 then    }
     { the sign bits from the upper 16 bits are shifted in rather than  }
     { zeroes.                                                          }
-    Result := SmallInt(((Word(AValue) shr 8) or (Word(AValue) shl 8)) and $ffff);
+    Result := SmallInt((Word(AValue) shr 8) or (Word(AValue) shl 8));
   end;
 
 {$ifndef cpujvm}
 function SwapEndian(const AValue: Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Result := ((AValue shr 8) or (AValue shl 8)) and $ffff;
+    Result := (AValue shr 8) or (AValue shl 8);
   end;
 {$endif}