src/com/google/javascript/jscomp/FunctionInjector.java
/**
   * @return Whether inlining will lower cost.
   */
@return Whether inlining will lower cost.
@return Whether inlining will lower cost .
private static boolean doesLowerCost(
      Node fnNode, int callCost,
      int directInlines, int costDeltaDirect,
      int blockInlines, int costDeltaBlock,
      boolean removable) {
    int fnInstanceCount = directInlines + blockInlines - (removable ? 1 : 0);
    if (fnInstanceCount == 0) {
      return blockInlines <= 0 || costDeltaBlock <= 0;
    }
    int costDelta = (directInlines * -costDeltaDirect) + (blockInlines * -costDeltaBlock);
    int threshold = (callCost + costDelta) / fnInstanceCount;
    return InlineCostEstimator.getCost(fnNode, threshold + 1) <= threshold;
  }
private static boolean doesLowerCost ( Node fnNode , int callCost , int directInlines , int costDeltaDirect , int blockInlines , int costDeltaBlock , boolean removable ) { int fnInstanceCount = directInlines + blockInlines - ( removable ? 1 : 0 ) ; if ( fnInstanceCount == 0 ) { return blockInlines <= 0 || costDeltaBlock <= 0 ; } int costDelta = ( directInlines * - costDeltaDirect ) + ( blockInlines * - costDeltaBlock ) ; int threshold = ( callCost + costDelta ) / fnInstanceCount ; return InlineCostEstimator . getCost ( fnNode , threshold + 1 ) <= threshold ; }
@return Whether inlining will lower cost.
@return Whether inlining will lower cost .
// Determine the threshold value for this inequality: //     inline_cost < call_cost // But solve it for the function declaration size so the size of it // is only calculated once and terminated early if possible. // Prevent division by zero. // Special case single reference function that are being block inlined: // If the cost of the inline is greater than the function definition size, // don't inline.