perf: avoid `setTransparency` when the transparency is already in effect This PR speeds up elaboration by not rebuilding the `MetaM` context when `withTransparency` or `withAtLeastTransparency` is asked for the transparency setting that is already in effect. `Context.setTransparency` rebuilds `Config`, `ConfigWithKey` and `Context`, so each such call allocated three objects and retraced the `Context`'s pointer fields even when nothing changed. `withTransparency` did this unconditionally, and `withAtLeastTransparency` did it by construction on the branch where the ambient mode already suffices. Both are hot: `withInferTypeConfig` wraps every `inferType` in `withAtLeastTransparency .default`, as does `getFunInfoAux`, and `.default` is usually the ambient mode already. Skipping the rebuild is observationally equivalent: `ConfigWithKey.key` is maintained as `Config.toKey`, whose low three bits are exactly `transparency.toUInt64`, so re-applying the current mode reproduces an identical `Config` and an identical key. Measured over 12 `elab_bench` files, 5 interleaved repetitions per variant against a same-machine baseline build: -0.33% instructions overall, with every file improving (-0.06% to -1.16%). The run-to-run noise floor for this metric is 0.10% per file and 0.00% overall. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This is the repository for Lean 4.
See Install Lean.
Please read our Contribution Guidelines first.
See Building Lean.