[Mono-dev] Should we replace MemoryStream?

Grzegorz Sobanski silk at boktor.net
Wed Nov 11 08:50:21 EST 2009


* Avery Pennarun <apenwarr at gmail.com> [2009-11-10 17:34]:
> might or might not result in the array being reallocated even in the
> *naive* implementation.  Each reallocation will cause a copy of the
> entire buffer every time.
> 
> Conversely, a chunked implementation would reallocate-and-copy the
> data at most once, when you call GetBuffer().  So it is strictly
> equal-or-better than the naive implementation, in terms of
> reallocations and copies.

Yes, it's true, but only partially.

Code that knows how naive is MemoryStream could absorb the reallocations,
maybe in some backgroud work. And the assume that GetBuffer is 
instantaneous (in GUI thread).

(Yes, this is purely academic point; No, I don't have such code;
No, I haven't seen one).

greets
silk


More information about the Mono-devel-list mailing list