mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-26 23:10:25 +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;
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user