Optimize JSON Array span methods
JSON Array.span, spanFrom, and spanTo currently leverage the underlying LinkedLists span methods:
shared actual Array span(Integer from, Integer to)
=> Array(list.span(from, to));
But list.span creates a copy of the list, as does the Array constructor. I suppose a non-shared constructor that skips the final copy could be used here.
Not sure if this is intentional or not, but reversed and rest are eager, despite List calling for lazy views.
Not sure if this is intentional or not, but
reversedandrestare eager, despiteListcalling for lazy views.
OK, we should fix that.
@jvasileff the problem is that LinkedList.span() * et. al.* are declared to return a plain List, but the rest of Array needs the list to be a LinkedList or at least MutableList, so a non-shared constructor it not sufficient: We'd need to refine the return type of span() etc on LinkedList (or MutableList) as well.
@tombentley alternatively you could just use sublist(), which returns something like a span without copying.
LinkedList.sublist() is currently not very efficient, but that's something on my list of things to optimize.
FTR: see #423.
Moving to 1.3