On Friday, 13 June 2014 at 22:12:01 UTC, Ali Çehreli wrote:
On 06/13/2014 03:02 PM, monarch_dodra wrote:

> No, it just receives a range, so it does range formating. eg:
> "[" ~ Element ~ ", " ~ Element ... "]".

It still looks like it could send the formatting characters as well as the elements separately to the output stream:

"["
Element
", "
...
"]"

I am assuming that the slowness in OP's example is due to constructing a long string.

Ali

We'd have to check, but don't think that formatted write actually ever allocates anywhere, so there should be no "constructing a long string". The real issue (I think), is that when you ask formatted write to write a string, it just pipes the entire char array at once to the underlying stream.

If the characters are escaped though (which is the case when you print an array of strings), then formatedWrite needs to check each character individually, and then also pass each character individually to the underlying stream. And *that* could definitely justify the order of magnitude slowdown observed.

What's more this *may* trigger a per-character decode-encode loop. I'd have to check. But that shouldn't be observable next to the stream overhead anyways.

Reply via email to