cleanup: use UncheckedArray instead of array[0, T]]

This commit is contained in:
Timothee Cour 2018-11-06 16:08:53 -08:00 committed by zah
parent 19645abeaf
commit 3b8e821b85
1 changed files with 1 additions and 4 deletions

View File

@ -160,10 +160,7 @@ proc `[]=`*[T, U, V](r: MutRange[T], s: HSlice[U, V], v: openarray[T]) =
raise newException(RangeError, "different lengths for slice assignment") raise newException(RangeError, "different lengths for slice assignment")
template toOpenArray*[T](r: Range[T]): auto = template toOpenArray*[T](r: Range[T]): auto =
# TODO: Casting through an {.unchecked.} array would be more appropriate toOpenArray(cast[ptr UncheckedArray[T]](r.start), 0, r.high)
# here, but currently this results in internal compiler error.
# NOTE: `0` in `array[0, T]` is irrelevant
toOpenArray(cast[ptr array[0, T]](r.start)[], 0, r.high)
proc `[]=`*[T, U, V](r: MutRange[T], s: HSlice[U, V], v: Range[T]) {.inline.} = proc `[]=`*[T, U, V](r: MutRange[T], s: HSlice[U, V], v: Range[T]) {.inline.} =
r[s] = toOpenArray(v) r[s] = toOpenArray(v)