Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid checking Scope.globals multiple times #16619

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented Jul 7, 2024

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Previously hasBinding was called on each parent scope, which resulted in multiple checks of Scope.globals and Scope.contextVariables.
This improvement is small, and I didn't notice a noticeable improvement in real-case-preset-env-typescript.

@liuxingbaoyu liuxingbaoyu added PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories pkg: traverse (scope) labels Jul 7, 2024
@liuxingbaoyu liuxingbaoyu changed the title Avoid checking Scope.globals multiple times. Avoid checking Scope.globals multiple times Jul 7, 2024
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57280

}
if (this.parentHasBinding(name, opts)) return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have other parentHasBinding usage? If not maybe we can deprecate and remove this method in Babel 8, as it is trivial to implement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has only this one use.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not label this as "performance", since the performance different is insignificant

@liuxingbaoyu liuxingbaoyu added PR: Polish 💅 A type of pull request used for our changelog categories and removed PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories labels Jul 8, 2024
@nicolo-ribaudo nicolo-ribaudo merged commit e0368a8 into babel:main Jul 9, 2024
51 checks passed
brandonb927 pushed a commit to brandonb927/brandonb-sites that referenced this pull request Jul 23, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@babel/preset-env](https://babel.dev/docs/en/next/babel-preset-env) ([source](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env)) | dependencies | patch | [`7.24.7` -> `7.24.8`](https://renovatebot.com/diffs/npm/@babel%2fpreset-env/7.24.7/7.24.8) |

---

### Release Notes

<details>
<summary>babel/babel (@&#8203;babel/preset-env)</summary>

### [`v7.24.8`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7248-2024-07-11)

[Compare Source](babel/babel@v7.24.7...v7.24.8)

##### 👓 Spec Compliance

-   `babel-parser`
    -   [#&#8203;16567](babel/babel#16567) Do not use strict mode in TS `declare` ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))

##### 🐛 Bug Fix

-   `babel-generator`
    -   [#&#8203;16630](babel/babel#16630) Correctly print parens around `in` in `for` heads ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
    -   [#&#8203;16626](babel/babel#16626) Fix printing of comments in `await using` ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
    -   [#&#8203;16591](babel/babel#16591) fix typescript code generation for yield expression inside type expre… ([@&#8203;SreeXD](https://github.com/SreeXD))
-   `babel-parser`
    -   [#&#8203;16613](babel/babel#16613) Disallow destructuring assignment in `using` declarations ([@&#8203;H0onnn](https://github.com/H0onnn))
    -   [#&#8203;16490](babel/babel#16490) fix: do not add `.value: undefined` to regexp literals ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))
-   `babel-types`
    -   [#&#8203;16615](babel/babel#16615) Remove boolean props from `ObjectTypeInternalSlot` visitor keys ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-plugin-transform-typescript`
    -   [#&#8203;16566](babel/babel#16566) fix: Correctly handle `export import x =` ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))

##### 💅 Polish

-   `babel-generator`
    -   [#&#8203;16625](babel/babel#16625) Avoid unnecessary parens around `async` in `for await` ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-traverse`
    -   [#&#8203;16619](babel/babel#16619) Avoid checking `Scope.globals` multiple times ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.brandonb.ca/brandon/personal-sites/pulls/3
Co-authored-by: Renovate Bot <renovate-bot@brandonb.ca>
Co-committed-by: Renovate Bot <renovate-bot@brandonb.ca>
brandonb927 pushed a commit to brandonb927/brandonb-sites that referenced this pull request Jul 23, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@babel/core](https://babel.dev/docs/en/next/babel-core) ([source](https://github.com/babel/babel/tree/HEAD/packages/babel-core)) | dependencies | patch | [`7.24.7` -> `7.24.9`](https://renovatebot.com/diffs/npm/@babel%2fcore/7.24.7/7.24.9) |

---

### Release Notes

<details>
<summary>babel/babel (@&#8203;babel/core)</summary>

### [`v7.24.9`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7249-2024-07-15)

[Compare Source](babel/babel@v7.24.8...v7.24.9)

##### 🐛 Bug Fix

-   `babel-core`, `babel-standalone`
    -   [#&#8203;16639](babel/babel#16639) Avoid `require()` call in `@babel/standalone` bundle ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-types`
    -   [#&#8203;16638](babel/babel#16638) fix: provide legacy typings for TS < 4.1 ([@&#8203;JLHwung](https://github.com/JLHwung))

##### 💅 Polish

-   `babel-generator`, `babel-plugin-transform-optional-chaining`
    -   [#&#8203;16617](babel/babel#16617) Avoid extra parens in TS `as`/`satisfies` ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))

##### 🏠 Internal

-   `babel-helper-module-transforms`
    -   [#&#8203;16629](babel/babel#16629) Lazy top-level initializations for module transforms ([@&#8203;guybedford](https://github.com/guybedford))

### [`v7.24.8`](https://github.com/babel/babel/blob/HEAD/CHANGELOG.md#v7248-2024-07-11)

[Compare Source](babel/babel@v7.24.7...v7.24.8)

##### 👓 Spec Compliance

-   `babel-parser`
    -   [#&#8203;16567](babel/babel#16567) Do not use strict mode in TS `declare` ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))

##### 🐛 Bug Fix

-   `babel-generator`
    -   [#&#8203;16630](babel/babel#16630) Correctly print parens around `in` in `for` heads ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
    -   [#&#8203;16626](babel/babel#16626) Fix printing of comments in `await using` ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
    -   [#&#8203;16591](babel/babel#16591) fix typescript code generation for yield expression inside type expre… ([@&#8203;SreeXD](https://github.com/SreeXD))
-   `babel-parser`
    -   [#&#8203;16613](babel/babel#16613) Disallow destructuring assignment in `using` declarations ([@&#8203;H0onnn](https://github.com/H0onnn))
    -   [#&#8203;16490](babel/babel#16490) fix: do not add `.value: undefined` to regexp literals ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))
-   `babel-types`
    -   [#&#8203;16615](babel/babel#16615) Remove boolean props from `ObjectTypeInternalSlot` visitor keys ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-plugin-transform-typescript`
    -   [#&#8203;16566](babel/babel#16566) fix: Correctly handle `export import x =` ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))

##### 💅 Polish

-   `babel-generator`
    -   [#&#8203;16625](babel/babel#16625) Avoid unnecessary parens around `async` in `for await` ([@&#8203;nicolo-ribaudo](https://github.com/nicolo-ribaudo))
-   `babel-traverse`
    -   [#&#8203;16619](babel/babel#16619) Avoid checking `Scope.globals` multiple times ([@&#8203;liuxingbaoyu](https://github.com/liuxingbaoyu))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.brandonb.ca/brandon/personal-sites/pulls/2
Reviewed-by: brandon <brandon+gitea@brandonb.ca>
Co-authored-by: Renovate Bot <renovate-bot@brandonb.ca>
Co-committed-by: Renovate Bot <renovate-bot@brandonb.ca>
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: traverse (scope) PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants