mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
[dart2wasm] Tweak setRange error checking
Error checking copied from VM. New passing test: corelib/list_set_range_test Change-Id: Iaac3be44037bac5646498a733828ee1f71f0eeb6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275861 Reviewed-by: Aske Simon Christensen <askesc@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
parent
f652c7962b
commit
0a1e05acab
|
@ -70,6 +70,10 @@ const bool has63BitSmis = false;
|
|||
|
||||
class Lists {
|
||||
static void copy(List src, int srcStart, List dst, int dstStart, int count) {
|
||||
if (srcStart + count > src.length) {
|
||||
throw IterableElementError.tooFew();
|
||||
}
|
||||
|
||||
// TODO(askesc): Intrinsify for efficient copying
|
||||
if (srcStart < dstStart) {
|
||||
for (int i = srcStart + count - 1, j = dstStart + count - 1;
|
||||
|
|
|
@ -60,14 +60,10 @@ abstract class _ModifiableList<E> extends _ListBase<E> {
|
|||
|
||||
// List interface.
|
||||
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
|
||||
if (start < 0 || start > this.length) {
|
||||
throw new RangeError.range(start, 0, this.length);
|
||||
}
|
||||
if (end < start || end > this.length) {
|
||||
throw new RangeError.range(end, start, this.length);
|
||||
}
|
||||
RangeError.checkValidRange(start, end, this.length);
|
||||
int length = end - start;
|
||||
if (length == 0) return;
|
||||
RangeError.checkNotNegative(skipCount, "skipCount");
|
||||
if (identical(this, iterable)) {
|
||||
Lists.copy(this, skipCount, this, start, length);
|
||||
} else if (iterable is List<E>) {
|
||||
|
|
Loading…
Reference in a new issue