how can I improve speed of ```(min..max).toList```...
# announcements
a
how can I improve speed of
Copy code
(min..max).toList
it takes 5000 .. 50000 -> 6.516391 s to generate
s
Cache the result? Use the IntRange directly?
j
Or implement an IntRange-backed List yourself since the getter is just min + index
a
Thanks @jw
I don’t need to cache the result, since it is one time operation, but since it is during the component initialization. It would be nice to do it faster. Initially the range was small, but now it turned out that existing approach doesn’t work well 😄
a
this is somewhat faster
Copy code
measureNanoTime {
    val list = (5000..50000).toList()
}

measureNanoTime {
    val list = (5000..50000).let { range ->
        List(range.last - range.first + 1) { range.first + it }
    }
}
a
yah, it is. Thanks for advise
k
I'm mostly wondering why you need such a list