<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Ill blast myself before someone else blasts me 
;)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>You would expect strings to be faster than 
memorystreams, I've tested with tmemorystream with using setsize to preset the 
size of the stream, and it comes out at twice as quick as a normal string 
concatination.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>If you have some idea of how large the string you 
will be dealing might be, you can choose an appropriate block size to enlarge 
the memorystream by.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>If you take out the setsize, then obviously the 
stream routines are slower.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>So probably you can&nbsp;achieve fast string 
equivalents of this as well with setlength which will be even faster. Although 
you will then have to do some string copying (probably useing memcpy to be as 
fast as possible) to get string bits in their right places and you can no longer 
just go a + b.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Matt.</FONT></DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=matt@ferndigital.com href="mailto:matt@ferndigital.com">Matt Comb</A> 
  </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz 
  href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi 
  List</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, September 05, 2004 3:21 
  AM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [DUG] Fast String 
  concatenation</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=Arial size=2>Hey Ross, how big are you talking here?, the 
  string management routines are pretty optimized?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>You could consider instead using a tmemorystream 
  and writing it to that when you need to ?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>What sort of sizes are you dealing with in total 
  ?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Matt.</FONT></DIV>
  <BLOCKQUOTE 
  style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
    <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
    <DIV 
    style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
    <A title=ross@stationplaylist.com 
    href="mailto:ross@stationplaylist.com">Ross Levis</A> </DIV>
    <DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz 
    href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi 
    List</A> </DIV>
    <DIV style="FONT: 10pt arial"><B>Sent:</B> Saturday, September 04, 2004 9:48 
    PM</DIV>
    <DIV style="FONT: 10pt arial"><B>Subject:</B> [DUG] Fast String 
    concatenation</DIV>
    <DIV><BR></DIV>
    <DIV><FONT face=Arial size=2>Hi all</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>I need a fast/efficient way&nbsp;of building a 
    string from data within a loop.&nbsp;&nbsp;The string is getting longer and 
    longer and therefore reallocating the whole string in memory every 
    loop.&nbsp; Each loop it gets&nbsp;a few&nbsp;words added, perhaps an 
    average of&nbsp;30 bytes.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>I thought of doing a SetLength on the string 
    every 256 bytes or so, but I'm not sure of the best method 
    of&nbsp;moving&nbsp;the data into the correct position&nbsp;in the 
    string.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Any suggestions?</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
    <DIV><FONT face=Arial size=2>Ross.</FONT></DIV>
    <P>
    <HR>

    <P></P>_______________________________________________<BR>Delphi mailing 
    list<BR>Delphi@ns3.123.co.nz<BR>http://ns3.123.co.nz/mailman/listinfo/delphi<BR></BLOCKQUOTE>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>Delphi mailing 
  list<BR>Delphi@ns3.123.co.nz<BR>http://ns3.123.co.nz/mailman/listinfo/delphi<BR></BLOCKQUOTE></BODY></HTML>