Would Java inline method(s) during optimization?

后端 未结 6 2045
青春惊慌失措
青春惊慌失措 2020-11-29 05:46

I wonder if JVM/javac is smart enough to turn

// This line...
string a = foo();

string foo()
{
  return bar();
}

string bar()
{
  return some-complicated-s         


        
6条回答
  •  情话喂你
    2020-11-29 06:37

    The JVM will most likely inline. In general it's best to optimize for human readability. Let the JVM do the runtime optimization.

    JVM expert Brian Goetz says final has no impact on methods being inlined.

提交回复
热议问题