What is the performance impact of Scala implicit type conversions?

前端 未结 2 1331
囚心锁ツ
囚心锁ツ 2020-12-09 08:19

In Scala, is there a significant CPU or memory impact to using implicit type conversions to augment a class\'s functionality vs. other possible implementation choices?

2条回答
  •  难免孤独
    2020-12-09 08:19

    JVM can optimize away the extra object allocations, if it detects that would be worthy.

    This is important, because if you just inline things you end up with bigger methods, which might cause performance problems with cache or even decrease the chance of JVM applying other optimizations.

提交回复
热议问题