mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 19:39:31 +02:00
Don’t use explicit Move in Extract<T> and Swap<T>.
This commit is contained in:
parent
a6e7e3e743
commit
9dfbc38a50
@ -914,19 +914,23 @@ begin
|
||||
end;
|
||||
|
||||
generic function Extract<T>(var from: T) :T;
|
||||
type
|
||||
RawT = array[0 .. sizeof(T) - 1] of byte;
|
||||
begin
|
||||
Finalize(Result);
|
||||
Move(from,Result,SizeOf(T));
|
||||
RawT(Result):=RawT(from);
|
||||
Initialize(from);
|
||||
end;
|
||||
|
||||
generic procedure Swap<T>(var lhs,rhs: T);
|
||||
type
|
||||
RawT = array[0 .. sizeof(T) - 1] of byte;
|
||||
var
|
||||
tmp:array[0..sizeof(T)-1] of Byte;
|
||||
tmp:RawT;
|
||||
begin
|
||||
Move(lhs,tmp,sizeof(T));
|
||||
Move(rhs,lhs,sizeof(T));
|
||||
Move(tmp,rhs,sizeof(T));
|
||||
tmp:=RawT(lhs);
|
||||
RawT(lhs):=RawT(rhs);
|
||||
RawT(rhs):=tmp;
|
||||
end;
|
||||
|
||||
Function ArrayOfConstToStrArray(const Args: array of const) : TUTF8StringDynArray;
|
||||
|
Loading…
Reference in New Issue
Block a user