[Mono-dev] Trivial Enumerable Optimizations
Jonathan Pryor
jonpryor at vt.edu
Fri May 9 11:17:58 EDT 2008
On Fri, 2008-05-09 at 08:53 -0400, Avery Pennarun wrote:
> On 5/9/08, Jonathan Pryor <jonpryor at vt.edu> wrote:
> > catch {
> > // ignore; collection has > int.MaxValue elements,
> > // so count manually below.
> > }
> [...]
> > This will suffer an obvious performance penalty if the collection has
> > over int.MaxValue elements (assuming .Count throws an exception when
> > that happens), but as most (currently all?) collections will have less
> > than int.MaxValue elements, this should be a performance win.
>
> Hmm, are you sure you really want to count them all manually when
> there are greater than 2 billion elements in the data structure?
If the developer asks for a count, we have an obligation to provide a
count. Throwing an exception claiming "You're a moron to ask about size
on a collection this big" should not be acceptable.
- Jon
More information about the Mono-devel-list
mailing list