3 ms·
That's the point, though. Java's Optional<T> always incurs that extra cost, but e.g. Kotlin's T? doesn't have that (because ? just allows null), and Rust has an
by pdpi 4y ago
That's the point, though. Java's Optional<T> always incurs that extra cost, but e.g. Kotlin's T? doesn't have that (because ? just allows null), and Rust has an optimisation for Option<Box<T>> that reduces the representation to a single pointer (and the empty case is a null pointer). You absolutely can have that level of optimisation while still having the optional type.