arrays - Delphi TBytes - how to copy? -
point opimization here.
now:
type tsomeclass=class(tobject) private datawrite: tbytes; ... end; function tsomeclass.getpacket: tbytes; begin setlength(result, length(datawrite)); move(datawrite[0],result[0],length(datawrite)); end;
what want achieve:
function tsomeclass.getpacket: tbytes; begin result := datawrite; end;
because arrays in delphi pointers first element, latter , writes 4 bytes faster. correct?
that work note working on same byte array in client code calls getpacket
. might bad idea. consider network library additional compression or encryption on byte array. creates lot of possibilites interact class without using exposed interface - bad. imho copying better option here.
btw: how big arrays talking here?
Comments
Post a Comment