avoids boxing the Floats when you use the methods defined in that interface directly. But if you use it as an
AnimationSpec
, it's no different than
tween
and
spring
🙏 1
e
elye
04/10/2021, 1:42 AM
Thanks @Doris Liu.
Can you elaborate what is
boxing the Floats
a little more…
d
Doris Liu
04/10/2021, 2:45 AM
Auto-boxing for primitives happens when used in an interface of generic type (e.g.
Foo<Float>
).
Float*Spec
interface declares methods that accept primitive Float type parameters, therefore no autoboxing is needed when you use those methods. (They are in fact used in the low level animation system when all data types have been converted to floats.) But if you were to use
Float*Spec
as an
AnimationSpec<Float>
to pass to high level animation APIs, none of those linked methods will be used. Therefore in that case there's not much difference between
FloatSpringSpec
and
SpringSpec<Float>
.
e
elye
04/10/2021, 4:09 AM
Thanks very much @Doris Liu!
I guess, I make the below conclusion. Let me know if I get it wrong.
• If we have a primitive
Float
, then
Float*Spec
would be more efficient.
• If we are not using
Float
, we’ll have to use
tween
or
spring
• When using non-primitive
Float
, then both are the same.
d
Doris Liu
04/10/2021, 5:04 AM
That's not correct. 🙂 They are the same unless you call