var
  A, B: string;

begin
  A := 'A long string';
  // Deep copy: Creates a new string and copies all the bytes from A
  B := Copy (A, 1, Length (A));
  // Shalow copy: only copies the reference and increments reference count
  B := A;

----- Original Message ----- 
From: "Paul McKenzie" <[EMAIL PROTECTED]>
Sent: Wednesday, October 20, 2004 11:48 AM


Excellent thanks...  I will go with my option B.

Regards
Paul McKenzie
SMSS Ltd.
Wellington
New Zealand
  ----- Original Message ----- 
  From: Ross Levis
  To: NZ Borland Developers Group - Delphi List
  Sent: Wednesday, October 20, 2004 11:28 AM
  Subject: Re: [DUG] String Copying


  As someone pointed out recently, assigning a string to another string only
copies 4 bytes, no matter how big the string is.  Only the memory location
is copied unless the 2 references to the string go out of scope, in which
case the string is copied in it's entirety.  The Copy command, however, will
copy each byte of the string to a new memory location.

  Ross.
    ----- Original Message ----- 
    From: Kyley Harris
    To: NZ Borland Developers Group - Delphi List
    Sent: Wednesday, October 20, 2004 11:15 AM
    Subject: Re: [DUG] String Copying


    Not sure, but I get the feeling that writing a small test including a
timer and a loop will be the fastest answer ;)

    Paul McKenzie wrote:
      Is it much slower to copy part of a string "Copy(AStr, 2,
Lenght(AStr))" than it is to copy an entire string.

      I am look at doing this sort of thing reasonably often - for up to
1000 strings.


      Regards
      Paul McKenzie
      SMSS Ltd.
      Wellington
      New Zealand
--------------------------------------------------------------------------
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi


----------------------------------------------------------------------------


    _______________________________________________
    Delphi mailing list
    [EMAIL PROTECTED]
    http://ns3.123.co.nz/mailman/listinfo/delphi



----------------------------------------------------------------------------
--


  _______________________________________________
  Delphi mailing list
  [EMAIL PROTECTED]
  http://ns3.123.co.nz/mailman/listinfo/delphi



----------------------------------------------------------------------------
----


> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED]
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to