Browse Source

[PATCH 170/188] using FPC built int function to do arithmetical
shift-right.

From 888bece97b8bb2ba160638e56ab00f21dccd0a93 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Fri, 27 Mar 2020 14:24:47 -0400

git-svn-id: branches/wasm@46166 -

nickysn 5 years ago
parent
commit
4a4a024eb6
1 changed files with 1 additions and 10 deletions
  1. 1 10
      utils/wasmbin/lebutils.pas

+ 1 - 10
utils/wasmbin/lebutils.pas

@@ -80,24 +80,15 @@ end;
 procedure WriteS(src: TStream; vl: Int64; bits: integer);
 procedure WriteS(src: TStream; vl: Int64; bits: integer);
 var
 var
   more     : Boolean;
   more     : Boolean;
-  negative : Boolean;
   b : byte;
   b : byte;
 begin
 begin
-  negative := vl < 0;
-
   more := true;
   more := true;
-  negative := (vl < 0);
 
 
   if (bits < 0) then bits := sizeof(vl);
   if (bits < 0) then bits := sizeof(vl);
 
 
   while more do begin
   while more do begin
     b := (vl and $7f);
     b := (vl and $7f);
-    vl := vl shr 7;
-
-    { the following is only necessary if the implementation of >>= uses a
-       logical shift rather than an arithmetic shift for a signed left operand }
-    if (negative) then
-      vl := vl or ((not 0) shl (bits - 7)); // sign extend
+    vl := SarInt64(vl, 7);
 
 
     { sign bit of byte is second high order bit (0x40) }
     { sign bit of byte is second high order bit (0x40) }
     if ((vl = 0) and (b and $40 = 0))
     if ((vl = 0) and (b and $40 = 0))