Topic: Avoid unnecassary string concatenation.

http://karma.nucleuscms.org/item/27

Re: Avoid unnecassary string concatenation.

That's actually a rather good suggestion.

3 (edited by Jansson 2007-06-19 18:10)

Re: Avoid unnecassary string concatenation.

We thought about it, but the gain in performance (almost nothing) didn't weigh up the downside of confusion and code consistency.

Re: Avoid unnecassary string concatenation.

 <?php echo $cur_post['message']."\n" ?>

This one line can drain 64KB of RAM. Assuming that temporary strings remain in memory until the end of script execution (do they?) and that a user views 50 posts per page, with the absence of code cache, you can potentially drain > 3MB of RAM.

Plus it's good practice.

I also don't see what is so confusing about this.

Re: Avoid unnecassary string concatenation.

This one line can drain 64KB of RAM. Assuming that temporary strings remain in memory until the end of script execution (do they?)

I don't think that's a fair assumption to make (and no, I don't think they do) wink

I also don't see what is so confusing about this.

It's not very commonly used and thus people might be confused about it.
Also, the commas only work for echo, not normal string concatenation, which is the consistancy issue.

And as Jansson said, Rickard did some testing and found that the gains were minimal.