<commit_before>package net.starlark.java.eval;

import javax.annotation.Nullable;

class BcDynCallSite {
  private final StarlarkCallableLinkSig linkSig;

  BcDynCallSite(StarlarkCallableLinkSig linkSig) {
    this.linkSig = linkSig;
  }

  @Nullable
  private StarlarkCallableLinked linkedCache;

  Object call(StarlarkCallable callable, StarlarkThread thread, Object[] args, @Nullable Sequence<?> starArgs, @Nullable Dict<?, ?> kwargs)
      throws InterruptedException, EvalException {
    StarlarkCallableLinked linked = this.linkedCache;
    if (linked == null || linked.orig != callable) {
      this.linkedCache = linked = callable.linkCall(linkSig);
    }
    return linked.callLinked(thread, args, starArgs, kwargs);
  }
}<commit_msg>Slightly faster dot call<commit_after>package net.starlark.java.eval;

import javax.annotation.Nullable;

/** Call site for {@link BcInstr.Opcode#CALL} instruction. */
class BcDynCallSite {
  private final StarlarkCallableLinkSig linkSig;

  BcDynCallSite(StarlarkCallableLinkSig linkSig) {
    this.linkSig = linkSig;
  }

  @Nullable private StarlarkCallableLinked linkedCache;

  Object call(
      StarlarkCallable callable,
      StarlarkThread thread,
      Object[] args,
      @Nullable Sequence<?> starArgs,
      @Nullable Dict<?, ?> kwargs)
      throws InterruptedException, EvalException {
    if (callable instanceof BuiltinFunction) {
      // Skip caching for builtin functions for two reasons:
      // * linking does not really link anything for builtin functions
      // * when `CALL` instruction is used for builtin (as opposed to `CALL_LINKED`)
      //     it is likely instance call like `x.append`, so a function is a fresh object,
      //     and it will be cache miss anyway
      BuiltinFunction builtinFunction = (BuiltinFunction) callable;
      return builtinFunction.linkAndCall(linkSig, thread, args, starArgs, kwargs);
    }

    StarlarkCallableLinked linked = this.linkedCache;
    if (linked == null || linked.orig != callable) {
      this.linkedCache = linked = callable.linkCall(linkSig);
    }
    return linked.callLinked(thread, args, starArgs, kwargs);
  }
}
{'fraction_non_alphanumeric': 0.08993476234855545, 'fraction_numerical': 0.0, 'mean_word_length': 3.8465011286681716, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4673063', 'n_tokens_mistral': 632, 'n_tokens_neox': 625, 'n_words': 173}