Marc Knaup
08/24/2020, 1:33 PMwhen
expressions over a String with plenty of constant cases could be optimized somehow, e.g. by using tableswitches for 1st & 2nd character (esp. if latin) or by using hashes.
Right now such cases will just repeatedly call equals
which can be much slower.
For now I’m using a HashMap
with String
as key and a lambda as value but the lambdas will create a crazy amount of anonymous classes.
I’ve also tried a HashMap
to Int
and then use the Int
for the when
expression but for whatever reason that was slower 😮 Prbl. because of boxing.udalov
when
over strings where we switch on the hash code, and then compare the string with one of the patterns with that hash code. It’s basically the same as in Java. Can you provide an example where it doesn’t work?Marc Knaup
08/24/2020, 5:54 PM