I am working on a project that automatically converts a custom language to Java and is asked to make some basic code optimizations during the conversion process. For example, custom code might have something like:
if someFunction(a, b) > x:
do something
else:
return someFunction(a, b) + y
in this case, someFunction is called several times with the same inputs, so additional performance can be obtained by caching the value of someFunction () and calling it only once. Thus, an “optimized” version of the above code might look something like this:
var1 = someFunction(a, b)
if var1 > x:
do something
else:
return var1 + y
. Java , , . , . , , , , , , .
, .., , ? . .
1:
, .