If I am doing an awful lot of of `Map<String, T...
# stdlib
r
If I am doing an awful lot of of
Map<String, T> + Map<String, T>
as well as
Map<String, T>.distinct()
and this is showing up during profiling as a hotspot, is there some obvious optimization I can do that lets me keep calls to
plus
and
distinct
but makes it go faster? All involved classes are kotlin data classes so implement that hashCode
r
What exactly is
Map<String, T>.distinct()
? And can specify your goal a bit more? For example, what other operations are you doing on those maps?
Best to describe what you are trying to accomplish, as there are many many things such structure & operations can represent, and that can change the optimization significantly
r
Sorry the Map part was on the values so basically just
List<T>.distinct()
so its Map plus Map as one operation and distinct on Lists as another one
j
this is the point where you can evaluate whether creating an index (e.q. primitive array) is more efficient than calling distinct() which is just linkedHashSet().toList().
c
You could also replace your lists by sets, so no conversion needs to take place at all