[thelist] ASP String Concatenation vs. Response.Write
Aylard JA (James)
jaylard at equilon.com
Mon Feb 26 16:45:52 CST 2001
Matt,
> As I understand it, it is true that concatenation is slower. But, it
depends
> on exactly what you're talking about.
That makes sense. I can see two ways of concatenating that are
similar, but the one approach would seem obviously faster than the other:
strOutput = "Some static text and " & _
someVariable & " some more text, " & _
"and yet " & anotherVariable & _
" still some more text that could go on forever."
would seem faster than
strOutput = "Some static text and "
strOutput = strOutput & someVariable & " some more text, "
strOutput = strOutput & "and yet " & anotherVariable
strOutput = strOutput & " still some more text that could go on forever."
(Caveat: I haven't actually tested one approach against the other to
see which is faster.)
But if you are iterating through a database recordset, for example,
where you could either concatenate an ever-growing string of database
results, or Response.Write the data after each loop through the recordset,
the Response.Write approach would almost certainly be significantly faster,
especially with a large recordset. Right?
James Aylard
More information about the thelist
mailing list