avoid synthetic lambda creation

This commit is contained in:
Leijurv 2018-10-03 07:48:26 -07:00
parent 04d210bd8b
commit cd926283b3
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -67,7 +67,14 @@ public class ToolSet implements Helper {
* @return how long it would take in ticks * @return how long it would take in ticks
*/ */
public double getStrVsBlock(IBlockState state) { public double getStrVsBlock(IBlockState state) {
return this.breakStrengthCache.computeIfAbsent(state.getBlock(), b -> calculateStrVsBlock(getBestSlot(state), state)); Double strength = this.breakStrengthCache.get(state.getBlock());
if (strength != null) {
// the function will take this path >99% of the time
return strength;
}
double str = calculateStrVsBlock(getBestSlot(state), state);
this.breakStrengthCache.put(state.getBlock(), str);
return str;
} }
/** /**