perf: reorder hot-path boolean checks to short-circuit on cheap predicates first#9523
Merged
Merged
Conversation
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
shulaoda
approved these changes
May 23, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
Member
Author
Merge activity
|
…cates first (#9523) ## Summary Across AST scanning, side-effect detection, finalizer traversal, and linker binding passes, swap chained `&&`/`||` operands so the cheapest, most-selective check runs first. No behavior changes — only operand reordering. - **`impl_visit.rs`** (2 sites): atom equality (`id.name == "module"`, `static_property_name() == Some("exports")`) before `is_global_identifier_reference()` scope lookup for `module.exports` detection. - **`side_effect_detector/mod.rs::check_pure_cjs_export`**: `ident.name == "exports"` before `is_unresolved` scope lookup. - **`cjs_export_analyzer.rs::check_assignment_is_cjs_reexport`**: `arguments.len() == 1` before `resolve_identifier_reference`. - **`cjs_export_analyzer.rs::is_object_define_property_es_module`**: `Object`/`defineProperty`/`exports` atom checks before scope hashmap lookups. - **`ast_scanner/mod.rs::extract_constant_value_from_expr`**: switch `options.optimization.is_inline_const_enabled()` → cached `flat_options.inline_const_enabled()` (single bitflag check instead of pointer-chasing). - **`renamer.rs::add_symbol_in_root_scope`**: 1-byte ASCII check before symbol-flag lookup. - **`bind_imports_and_exports.rs`**: `exported_name == "default"` before `!came_from_commonjs` in the per-named-export filter loop. - **`wrapping.rs`**: reuse the already-cached `on_demand_wrapping` local instead of recomputing `is_on_demand_wrapping_enabled()` inside the loop. - **`impl_traverse_for_hmr_ast_finalizer.rs`**: gate the `this_expr_replace_map.contains_key()` hashmap lookup behind the module-wide `exports_kind.is_commonjs()` check. - **`expression_ext.rs`** (3 sites): atom equality on property name before recursive `is_import_meta*()` shape probe. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
0accf24 to
07c5330
Compare
V1OL3TF0X
pushed a commit
to V1OL3TF0X/rolldown
that referenced
this pull request
May 25, 2026
…cates first (rolldown#9523) ## Summary Across AST scanning, side-effect detection, finalizer traversal, and linker binding passes, swap chained `&&`/`||` operands so the cheapest, most-selective check runs first. No behavior changes — only operand reordering. - **`impl_visit.rs`** (2 sites): atom equality (`id.name == "module"`, `static_property_name() == Some("exports")`) before `is_global_identifier_reference()` scope lookup for `module.exports` detection. - **`side_effect_detector/mod.rs::check_pure_cjs_export`**: `ident.name == "exports"` before `is_unresolved` scope lookup. - **`cjs_export_analyzer.rs::check_assignment_is_cjs_reexport`**: `arguments.len() == 1` before `resolve_identifier_reference`. - **`cjs_export_analyzer.rs::is_object_define_property_es_module`**: `Object`/`defineProperty`/`exports` atom checks before scope hashmap lookups. - **`ast_scanner/mod.rs::extract_constant_value_from_expr`**: switch `options.optimization.is_inline_const_enabled()` → cached `flat_options.inline_const_enabled()` (single bitflag check instead of pointer-chasing). - **`renamer.rs::add_symbol_in_root_scope`**: 1-byte ASCII check before symbol-flag lookup. - **`bind_imports_and_exports.rs`**: `exported_name == "default"` before `!came_from_commonjs` in the per-named-export filter loop. - **`wrapping.rs`**: reuse the already-cached `on_demand_wrapping` local instead of recomputing `is_on_demand_wrapping_enabled()` inside the loop. - **`impl_traverse_for_hmr_ast_finalizer.rs`**: gate the `this_expr_replace_map.contains_key()` hashmap lookup behind the module-wide `exports_kind.is_commonjs()` check. - **`expression_ext.rs`** (3 sites): atom equality on property name before recursive `is_import_meta*()` shape probe. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Merged
shulaoda
added a commit
that referenced
this pull request
May 27, 2026
## [1.0.3] - 2026-05-27 ### 🚀 Features - transform: respect decorator strictNullChecks option (#9580) by @kylecannon - drop `defer` keyword (#9503) by @TheAlexLichter ### 🐛 Bug Fixes - ci: create target dir before cargo release-oxc update (#9584) by @shulaoda - ci: reorder prepare-release steps to avoid dirty git check failure (#9583) by @shulaoda - testing: canonicalize temp dir early and use platform-specific separator in test262 (#9582) by @shulaoda - testing: resolve symlinked temp dir in test262 snapshot normalization (#9581) by @shulaoda - testing: canonicalize temp dir path in test262 snapshot normalization (#9579) by @shulaoda - dev: `onOutput` called twice when initial build fails (#9552) by @hyf0 - dev: make `ensureCurrentBuildFinish` not returning error when engine closes (#9564) by @h-a-n-a - oxc-runtime: route require() to CJS helper variant (#9263) (#9526) by @IWANABETHATGUY - generator: use exporter chunk's export mode for CJS default re-exports (#9299) (#9529) by @IWANABETHATGUY - rolldown: always run reduced-atom static cycle check (#9441) (#9514) by @IWANABETHATGUY - apply transform.dropLabels before scanning (#9521) (#9522) by @IWANABETHATGUY - rolldown_watcher: take `rolldown` dep through the workspace (#9510) by @Boshen - cache: keep the scan-stage cache consistent when a build fails (#9495) by @h-a-n-a - skip JSON default-import namespace optimization for write targets (#9484) (#9489) by @IWANABETHATGUY - deps: skip pnpm frozen-lockfile on Netlify to dodge catalog mismatch bug (#9471) by @Boshen ### 🚜 Refactor - oxc-runtime: use Cow for helper path construction (#9538) by @IWANABETHATGUY - fold import defer phase drop into PreProcessor (#9524) by @IWANABETHATGUY - distinguish `map: null` vs `map: undefined` in transform hook output (#9497) by @sapphi-red ### 📚 Documentation - explain the policy for Rust crates (#9547) by @sapphi-red - cache: add design doc for cache (#9544) by @h-a-n-a - guide/troubleshooting: add TDZ error section (#9537) by @sapphi-red - dev-engine: add design doc for dev-engine (#9479) by @h-a-n-a - lazy-barrel: tweak some words (#9483) by @shulaoda - lazy-barrel: expand reasoning behind LARGE_BARREL_MODULES advice (#9477) by @shulaoda ### ⚡ Performance - generate: thread ast_table by value into codegen consumer (#9555) by @Boshen - finalizers: replace `_reExport` construction with a direct call to avoid calling `clone_in` (#9501) by @Dunqing - reorder hot-path boolean checks to short-circuit on cheap predicates first (#9523) by @Boshen ### 🧪 Testing - rolldown: regression fixture for #9401 (#9418) by @IWANABETHATGUY - failing test for #9441 (#9504) by @TheAlexLichter ### ⚙️ Miscellaneous Tasks - deps: upgrade oxc to 0.133.0 (#9563) by @Dunqing - deps: update crate-ci/typos action to v1.46.3 (#9576) by @renovate[bot] - deps: update mimalloc-safe to 0.1.62 (#9577) by @shulaoda - mimalloc-safe: update to a bug-fix branch for verification (#9569) by @shulaoda - deps: update test262 submodule for tests (#9551) by @rolldown-guard[bot] - point published crates' readme to root README.md (#9553) by @Boshen - replace actions-cool/issues-helper with gh CLI (#9543) by @Boshen - deps: update cargo-shear to 1.12.4 (#9541) by @Boshen - deps: update taiki-e/install-action action to v2.79.4 (#9535) by @renovate[bot] - deps: update github actions (#9532) by @renovate[bot] - deps: update rust crates (#9534) by @renovate[bot] - deps: update npm packages (#9533) by @renovate[bot] - gate experimental/testing-only items to silence dead_code in publish builds (#9517) by @Boshen - docs: deploy to Void (#9509) by @Boshen - release: set up cargo-release-oxc for publishing crates (#9476) by @Boshen - rolldown_plugin_lazy_compilation: add missing description (#9507) by @Boshen - mimalloc-safe: update to a bug-fix branch for verification (#9506) by @shulaoda - deps: update crate-ci/typos action to v1.46.2 (#9468) by @renovate[bot] ### ❤️ New Contributors * @kylecannon made their first contribution in [#9580](#9580)
shulaoda
pushed a commit
that referenced
this pull request
May 27, 2026
## [1.0.3] - 2026-05-27 ### 🚀 Features - transform: respect decorator strictNullChecks option (#9580) by @kylecannon - drop `defer` keyword (#9503) by @TheAlexLichter ### 🐛 Bug Fixes - ci: create target dir before cargo release-oxc update (#9584) by @shulaoda - ci: reorder prepare-release steps to avoid dirty git check failure (#9583) by @shulaoda - testing: canonicalize temp dir early and use platform-specific separator in test262 (#9582) by @shulaoda - testing: resolve symlinked temp dir in test262 snapshot normalization (#9581) by @shulaoda - testing: canonicalize temp dir path in test262 snapshot normalization (#9579) by @shulaoda - dev: `onOutput` called twice when initial build fails (#9552) by @hyf0 - dev: make `ensureCurrentBuildFinish` not returning error when engine closes (#9564) by @h-a-n-a - oxc-runtime: route require() to CJS helper variant (#9263) (#9526) by @IWANABETHATGUY - generator: use exporter chunk's export mode for CJS default re-exports (#9299) (#9529) by @IWANABETHATGUY - rolldown: always run reduced-atom static cycle check (#9441) (#9514) by @IWANABETHATGUY - apply transform.dropLabels before scanning (#9521) (#9522) by @IWANABETHATGUY - rolldown_watcher: take `rolldown` dep through the workspace (#9510) by @Boshen - cache: keep the scan-stage cache consistent when a build fails (#9495) by @h-a-n-a - skip JSON default-import namespace optimization for write targets (#9484) (#9489) by @IWANABETHATGUY - deps: skip pnpm frozen-lockfile on Netlify to dodge catalog mismatch bug (#9471) by @Boshen ### 🚜 Refactor - oxc-runtime: use Cow for helper path construction (#9538) by @IWANABETHATGUY - fold import defer phase drop into PreProcessor (#9524) by @IWANABETHATGUY - distinguish `map: null` vs `map: undefined` in transform hook output (#9497) by @sapphi-red ### 📚 Documentation - explain the policy for Rust crates (#9547) by @sapphi-red - cache: add design doc for cache (#9544) by @h-a-n-a - guide/troubleshooting: add TDZ error section (#9537) by @sapphi-red - dev-engine: add design doc for dev-engine (#9479) by @h-a-n-a - lazy-barrel: tweak some words (#9483) by @shulaoda - lazy-barrel: expand reasoning behind LARGE_BARREL_MODULES advice (#9477) by @shulaoda ### ⚡ Performance - generate: thread ast_table by value into codegen consumer (#9555) by @Boshen - finalizers: replace `_reExport` construction with a direct call to avoid calling `clone_in` (#9501) by @Dunqing - reorder hot-path boolean checks to short-circuit on cheap predicates first (#9523) by @Boshen ### 🧪 Testing - rolldown: regression fixture for #9401 (#9418) by @IWANABETHATGUY - failing test for #9441 (#9504) by @TheAlexLichter ### ⚙️ Miscellaneous Tasks - deps: upgrade oxc to 0.133.0 (#9563) by @Dunqing - deps: update crate-ci/typos action to v1.46.3 (#9576) by @renovate[bot] - deps: update mimalloc-safe to 0.1.62 (#9577) by @shulaoda - mimalloc-safe: update to a bug-fix branch for verification (#9569) by @shulaoda - deps: update test262 submodule for tests (#9551) by @rolldown-guard[bot] - point published crates' readme to root README.md (#9553) by @Boshen - replace actions-cool/issues-helper with gh CLI (#9543) by @Boshen - deps: update cargo-shear to 1.12.4 (#9541) by @Boshen - deps: update taiki-e/install-action action to v2.79.4 (#9535) by @renovate[bot] - deps: update github actions (#9532) by @renovate[bot] - deps: update rust crates (#9534) by @renovate[bot] - deps: update npm packages (#9533) by @renovate[bot] - gate experimental/testing-only items to silence dead_code in publish builds (#9517) by @Boshen - docs: deploy to Void (#9509) by @Boshen - release: set up cargo-release-oxc for publishing crates (#9476) by @Boshen - rolldown_plugin_lazy_compilation: add missing description (#9507) by @Boshen - mimalloc-safe: update to a bug-fix branch for verification (#9506) by @shulaoda - deps: update crate-ci/typos action to v1.46.2 (#9468) by @renovate[bot] ### ❤️ New Contributors * @kylecannon made their first contribution in [#9580](#9580)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Across AST scanning, side-effect detection, finalizer traversal, and linker binding passes, swap chained
&&/||operands so the cheapest, most-selective check runs first. No behavior changes — only operand reordering.impl_visit.rs(2 sites): atom equality (id.name == "module",static_property_name() == Some("exports")) beforeis_global_identifier_reference()scope lookup formodule.exportsdetection.side_effect_detector/mod.rs::check_pure_cjs_export:ident.name == "exports"beforeis_unresolvedscope lookup.cjs_export_analyzer.rs::check_assignment_is_cjs_reexport:arguments.len() == 1beforeresolve_identifier_reference.cjs_export_analyzer.rs::is_object_define_property_es_module:Object/defineProperty/exportsatom checks before scope hashmap lookups.ast_scanner/mod.rs::extract_constant_value_from_expr: switchoptions.optimization.is_inline_const_enabled()→ cachedflat_options.inline_const_enabled()(single bitflag check instead of pointer-chasing).renamer.rs::add_symbol_in_root_scope: 1-byte ASCII check before symbol-flag lookup.bind_imports_and_exports.rs:exported_name == "default"before!came_from_commonjsin the per-named-export filter loop.wrapping.rs: reuse the already-cachedon_demand_wrappinglocal instead of recomputingis_on_demand_wrapping_enabled()inside the loop.impl_traverse_for_hmr_ast_finalizer.rs: gate thethis_expr_replace_map.contains_key()hashmap lookup behind the module-wideexports_kind.is_commonjs()check.expression_ext.rs(3 sites): atom equality on property name before recursiveis_import_meta*()shape probe.🤖 Generated with Claude Code