New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More efficient ArraySeq iteration #8300
Conversation
in test/files/run/serialize-stream.scala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stepper change LGTM
The serialization change is problematic. |
We could have a private, Serailizable subclass of Is there a general story / spec about iterators being serializable? |
Hm, right. On second thought, making those classes |
Ah right, |
The MiMa errors are strange:
The signatures are the same but it complains about the methods both ways. (And contrary to what I originally suspected, relaxing accessibility of |
91e0b9e
to
4daa59b
Compare
- Use `ArrayIterator` for `ArraySeq`: As discovered in scala/bug#11658, `ArraySeq` (both mutable and immutable) used the generic `IndexedSeqView`-based iterators even though the more efficient `ArrayIterator` is available. - Avoid runtime type checks for `ArraySeq` steppers: `ArraySeq.stepper` had to perform a runtime type check for the array. Now there are separate implementations for all specialized `ArraySeq` types that avoid the extra checks. - Add a useful `knownSize` implementation to `ArrayIterator`.
I examined the signatures manually. The MiMa errors are confusing and the wording of the first one ("abstract method ... does not have a correspondent in current version") is plain wrong. The actual change is as follows: Old (concrete stepper implementation in ArraySeq):
New (abstract stepper declaration):
So whereas the first error message gives the impression that the old version had an abstract method, it is in fact the new version. We could leave out the abstract declaration to satisfy MiMa but it wouldn't be source compatible. It exists to refine the return type from |
4daa59b
to
946414c
Compare
@lrytz Any further comments on this? |
@szeiger Just saw this. In case you want to revisit this, this might be fixed in current MiMa but if not we could improve it. |
Use
ArrayIterator
forArraySeq
: As discovered inScala 2.13 Iterator .take() method converts dropped values into null bug#11658,
ArraySeq
(both mutableand immutable) used the generic
IndexedSeqView
-based iterators eventhough the more efficient
ArrayIterator
is available.Avoid runtime type checks for
ArraySeq
steppers:ArraySeq.stepper
had to perform a runtime type check for the array. Now there are
separate implementations for all specialized
ArraySeq
types thatavoid the extra checks.
Add a useful
knownSize
implementation toArrayIterator
.