https://kotlinlang.org logo
Title
e

elect

06/15/2017, 10:31 AM
if I rewrite this
fun findWindowSettings(name:String): IniData? {
    val id = hash(name, 0)
    return g.settings.firstOrNull { it.id == id }
}
as
fun findWindowSettings(name:String) = g.settings.firstOrNull { it.id == hash(name, 0) }
will be the
hash()
result cached or executed each time?
m

marstran

06/15/2017, 11:02 AM
elect: It will be executed each time.
e

elect

06/15/2017, 11:05 AM
then I'll leave as it is, thanks
c

cedric

06/15/2017, 4:29 PM
@elect Also, I might be missing some context on your code but basing equality on hashing is dangerous since two different objects can have the same hash
e

elect

06/15/2017, 4:30 PM
thanks for the tip
however I am just porting imgui to kotlin
that's how he is doing