Browse Source

* Make tscoped.assign the less expensive operation

Michaël Van Canneyt 3 months ago
parent
commit
b590ad70d8
1 changed files with 2 additions and 3 deletions
  1. 2 3
      rtl/objpas/types.pp

+ 2 - 3
rtl/objpas/types.pp

@@ -528,7 +528,6 @@ type
     function Get : T;
   end;
 
-
 function EqualRect(const r1,r2 : TRect) : Boolean;
 function EqualRect(const r1,r2 : TRectF) : Boolean;
 function NormalizeRectF(const Pts: array of TPointF): TRectF; overload;
@@ -2082,7 +2081,7 @@ end;
 
 procedure TScoped.Assign(aObj : T);
 begin
-  Swap(aObj);
+  Self.Obj:=aObj;
 end;
 
 function TScoped.Swap(AObj:T):T;
@@ -2090,7 +2089,7 @@ var
   LCurrent:T;
 begin
   LCurrent := self.obj;
-  self.obj := AObj;
+  Assign(AObj);
   Result := LCurrent;
 end;