This page is no longer maintained — Please continue to the home page at www.scala-lang.org

SeqLike.equals and IterableLike.sameElements efficiency

No replies
Andrew McCallum
Joined: 2009-06-30,
User offline. Last seen 42 years 45 weeks ago.

According to my quick reading of the code, neither SeqLike.equals or IterableLike.sameElements check for "this eq that" and returning "true" before doing the work of comparing all containing elements. For large collections (especially with non-trivially-compared elements) this is a significant lost opportunity for efficiency.

Is there a reason not to perform this "eq" check?

I noticed this for SeqLike, but perhaps MapLike and elsewhere should get the same treatment as well.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland