list literal gotcha and suggestion
Mark Thornton
mthornton at optrak.co.uk
Wed Sep 30 00:51:55 PDT 2009
Reinier Zwitserloot wrote:
> NB: Gene, you're trying to argue that a _literal_ set is going to make
> some sort of speed difference compared to a a_literal_ list. That
> notion is frankly ridiculous. You also lost track of the first rule of
> discussing speed: Test it first. So, go ahead. Benchmark a bunch
>
No, I think he is arguing that many people have used ArrayList in place
of what should have been a Set. That is a List is used with
supplementary documentation to the effect that the elements in the list
occur once only and usually that the order isn't important. In other
words ArrayList is used because it is more compact and faster to
iterate. All this naturally having been done without testing if it is
really important. Another reason for some excess use of List in existing
code is that Arrays.asList() is the most compact way of creating a
collection with more than one element (excluding EnumSet's).
Mark Thornton
More information about the coin-dev
mailing list