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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -