Don’t use explicit Move in Extract<T> and Swap<T>.

This commit is contained in:
Rika Ichinose 2024-11-29 09:42:09 +03:00 committed by FPK
parent a6e7e3e743
commit 9dfbc38a50

View File

@ -914,19 +914,23 @@ begin
end; end;
generic function Extract<T>(var from: T) :T; generic function Extract<T>(var from: T) :T;
type
RawT = array[0 .. sizeof(T) - 1] of byte;
begin begin
Finalize(Result); Finalize(Result);
Move(from,Result,SizeOf(T)); RawT(Result):=RawT(from);
Initialize(from); Initialize(from);
end; end;
generic procedure Swap<T>(var lhs,rhs: T); generic procedure Swap<T>(var lhs,rhs: T);
type
RawT = array[0 .. sizeof(T) - 1] of byte;
var var
tmp:array[0..sizeof(T)-1] of Byte; tmp:RawT;
begin begin
Move(lhs,tmp,sizeof(T)); tmp:=RawT(lhs);
Move(rhs,lhs,sizeof(T)); RawT(lhs):=RawT(rhs);
Move(tmp,rhs,sizeof(T)); RawT(rhs):=tmp;
end; end;
Function ArrayOfConstToStrArray(const Args: array of const) : TUTF8StringDynArray; Function ArrayOfConstToStrArray(const Args: array of const) : TUTF8StringDynArray;