java how expensive is a method call

后端 未结 12 1595
情书的邮戳
情书的邮戳 2020-11-27 04:04

I\'m a beginner and I\'ve always read that it\'s bad to repeat code. However, it seems that in order to not do so, you would have to have extra method calls usually. Let\'s

12条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 04:54

    The best practice is to measure twice and cut once.

    Once you've wasted time optimization, you can never get it back again! (So measure it first and ask yourself if it's worth optimisation. How much actual time will you save?)

    In this case, the Java VM is probably already doing the optimization you are talking about.

提交回复
热议问题