ursus
09/20/2021, 1:22 AMMap<String, String>
(keyed labels of UI elements), which is created dynamically via fetching the labels from api -- so not statically with string literals.
Does it make sense to implement a Trie
or is this somehow optimized under the hood in jvm since String
is so special?
I remember faintly about string interning, but that only applies to string literals and deals with copies, right?
It might be more memory efficient, however what about lookup? I believe there are native implementations of this inside when simply matching Strings
, no?
Also, turning unicode strings to char arrays won't work all that great?crummy
09/20/2021, 1:28 AMursus
09/20/2021, 1:32 AM"usage_weekly": "/ týždeň",
"used_1_data": "použitý",
"used_1_min": "prevolaná minúta",
"used_1_sms": "odoslaná správa",
"used_24_data": "použité",
"used_24_min": "prevolané minúty",
"used_24_sms": "odoslané správy",
"used_x_data": "použitých",
"used_x_min": "prevolaných minút",
"used_x_sms": "odoslaných správ",
so, trie could optimize the sizeursus
09/20/2021, 1:34 AMChar
is a class in kotlin, I presume charArrayOf('a', 'b', 'c')
creates 3 Char instances on heap; which I fear would nulify anything; as opposed to java where its just primitive intsursus
09/20/2021, 1:36 AMpublic class Char private constructor() : Comparable<Char> {
public fun toInt(): Int
}
I dont even understand what is this, virtual method with no implementation in a concrete class, huh?ursus
09/20/2021, 2:17 AMcrummy
09/20/2021, 2:27 AMDidier Villevalois
09/20/2021, 5:51 AMChar
is handled under the hood as char
on the JVM. However, there are cases where the JVM uses boxes around those primitives. For instance, List<Char>
boxes the characters but CharArray
does not.
Also, String
are interned on the JVM. I can't say about the performance however. In general, the JVM is very good at optimizing standard patterns. You should not try to prematurely and manually optimize things.ursus
09/20/2021, 5:58 AMephemient
09/20/2021, 7:46 AMephemient
09/20/2021, 7:56 AMursus
09/20/2021, 12:45 PMephemient
09/20/2021, 5:15 PMursus
09/20/2021, 7:56 PMephemient
09/20/2021, 8:28 PMephemient
09/20/2021, 8:31 PMursus
09/20/2021, 10:32 PM