Readability vs Performance

后端 未结 3 1736

Recently we had a discussion at work about the impact of local variables on the performance vs readability of Java code. Some of my colleagues are of the oppinion that declarati

3条回答
  •  萌比男神i
    2021-02-13 02:43

    Are they right in claiming this?

    No, they are not. The cost of storing something in a local variable and then subsequently reading from it is next to 0, it's as simple as that -- this is definitely not something that you should spend your time optimizing, or even worrying about for that matter. Don't sacrifice readability by putting everything in a single, highly convoluted line.

提交回复
热议问题