2015-03-10 15:09 GMT-03:00 sergio_101 <sergio....@gmail.com>:
>
> it seems that in more cases than not, i find that developers use a stream
> when concatenating some text strings.
>
> I am wondering if this is a smalltalk thing, or is there a real speed
> benefit when using streams in this way.

It is not a matter of speed only, but mostly memory.

For large text concatenations Streams are more memory efficient
because you don't create intermediate strings.

E.g.
'string1', 'string2', 'string3' ... , "stringN" will require the
creation of N intermediate String instances.

aStream
  nextPutAll: 'string1';
  nextPutAll: 'string2';
  nextPutAll: 'string3';
  nextPutAll: 'stringN'

Will only add contents to the Stream collection.


Esteban A. Maringolo

Reply via email to