I am working on moving away from using AnsiString as communications buffer in an old application, so I need to write efficient replacements for certain string functions (Delete, Insert, Copy etc).
Now I am wondering if there is a better way to do the Insert() command than this: procedure InsertBytes(var Dest: TBytes; Src: TBytes; Index: integer); var Len, LenA: integer; begin Len := Length(Dest); LenA := Length(Src); if LenA = 0 then exit; //Do nothing if Index > Len then Index := Len; //Make an append instead SetLength(Dest, Len + LenA); Move(Dest[Index], Dest[Index + LenA], LenA); //Create space Move(Src[0], Dest[Index], LenA); //Insert data end; Ideally the function should be portable between FPC and Delphi XE5... -- Bo Berglund Developer in Sweden _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal