ImmutableArrayList.subList: return this if fromIndex = 0 and toIndex = length

This commit is contained in:
Stepan Koltsov
2012-05-18 15:03:10 +04:00
parent 32f83f0587
commit e2a875286b
@@ -47,6 +47,9 @@ private class ImmutableArrayList<T>(
if (toIndex > length) {
throw IndexOutOfBoundsException("fromIndex ($fromIndex) + toIndex ($toIndex) > length ($length)")
}
if (fromIndex == 0 && toIndex == length) {
return this
}
return ImmutableArrayList(array, offset + fromIndex, toIndex - fromIndex)
}