maidh91 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

*Multiset.create(Iterable) does not optimize for the case of the Iterable being another Multiset #421

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For example, if I have an EnumMultiset foo, and call EnumMultiset.create(foo) 
to make a copy of it, it will iterator over every (duplicated) element in the 
multiset. It should instead use the optimized implementation in 
Multisets.addAllImpl().

Original issue reported on code.google.com by ray.j.gr...@gmail.com on 16 Sep 2010 at 9:59

GoogleCodeExporter commented 9 years ago
Wow, nice catch, we'll check for places like this we missed.

Original comment by kevinb@google.com on 17 Sep 2010 at 3:46

GoogleCodeExporter commented 9 years ago
Wait -- are you sure it does this?  We seem to use Iterables.addAll, which 
calls back to Multiset.addAll if its second argument is any Collection type.  
And all our Multisets do use Multisets.addAllImpl, by inheriting 
AbstractMultiset.addAll.

Please reopen if I'm mistaken.

Original comment by kevinb@google.com on 22 Sep 2010 at 5:28

GoogleCodeExporter commented 9 years ago
You're right.

I'm not sure how I brainfarted on this. Perhaps I was looking at the source to 
Iterators instead of Iterables?

Sorry for the misfire.

Original comment by ray.j.gr...@gmail.com on 22 Sep 2010 at 8:10

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09