Kotlin code:
import org.joda.time.*
class Test {
data class Foo(val value: Long, val name: String = "foo")
companion object {
@JvmStatic
fun main(args: Array<String>) {
Foo(value = DateTime.now().plusSeconds(86400).millis)
}
}
}
JD-GUI Java code:
public class Test {
@JvmStatic
public final void main(@NotNull String[] args) {
Intrinsics.checkParameterIsNotNull(args, "args");
Intrinsics.checkExpressionValueIsNotNull(DateTime.now().plusSeconds(86400), "DateTime.now().plusSeconds(86400)");
new Test.Foo(DateTime.now().plusSeconds(86400).getMillis(), null, 2, null);
}
}
Execute DateTime.now().plusSeconds(86400)
2 times, will this affect the efficiency of execution?
Should I extract another variable?
import org.joda.time.*
class Test {
data class Foo(val value: Long, val name: String = "foo")
companion object {
@JvmStatic
fun main(args: Array<String>) {
val tomorrow = DateTime.now().plusSeconds(86400).mills
Foo(value = tomorrow)
}
}
}