-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Floor for NewVectorIterator.slice limit #10518
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2389,12 +2389,14 @@ private final class NewVectorIterator[A](v: Vector[A], private[this] var totalLe | |
} | ||
|
||
override def slice(from: Int, until: Int): Iterator[A] = { | ||
val _until = | ||
val _until = mmax(until, 0) | ||
|
||
val n = | ||
if(from > 0) { | ||
drop(from) | ||
until - from | ||
} else until | ||
take(_until) | ||
_until - from | ||
} else _until | ||
take(n) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (until<= 0 || until<= from) Iterator.empty else {
if (from > 0) drop(from)
take(if(from < 0) until else until- from)
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unsure about your comment. Is this a third proposal? If so, I think it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Int = { | ||
|
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.
I think the most quick fix can be
mmax(util, 0)
, inline it here, otherwise lgtm.