ImmutableArrayList.subList: return this if fromIndex = 0 and toIndex = length
This commit is contained in:
@@ -47,6 +47,9 @@ private class ImmutableArrayList<T>(
|
|||||||
if (toIndex > length) {
|
if (toIndex > length) {
|
||||||
throw IndexOutOfBoundsException("fromIndex ($fromIndex) + toIndex ($toIndex) > length ($length)")
|
throw IndexOutOfBoundsException("fromIndex ($fromIndex) + toIndex ($toIndex) > length ($length)")
|
||||||
}
|
}
|
||||||
|
if (fromIndex == 0 && toIndex == length) {
|
||||||
|
return this
|
||||||
|
}
|
||||||
return ImmutableArrayList(array, offset + fromIndex, toIndex - fromIndex)
|
return ImmutableArrayList(array, offset + fromIndex, toIndex - fromIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user