Skip to content

perf(semantic): defer declare lookup for empty accessors#22810

Merged
graphite-app[bot] merged 1 commit into
mainfrom
c/05-28-perf_semantic_defer_declare_lookup_for_empty_accessors
May 28, 2026
Merged

perf(semantic): defer declare lookup for empty accessors#22810
graphite-app[bot] merged 1 commit into
mainfrom
c/05-28-perf_semantic_defer_declare_lookup_for_empty_accessors

Conversation

@camc314

@camc314 camc314 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Only compute whether the containing class is declare when checking empty-body TypeScript accessors. Ordinary methods and overload signatures do not need that value, so the hot method path can avoid repeated containing-class lookups.

@github-actions github-actions Bot added the A-semantic Area - Semantic label May 28, 2026

camc314 commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@camc314 camc314 marked this pull request as ready for review May 28, 2026 19:48
@camc314 camc314 requested a review from Dunqing as a code owner May 28, 2026 19:48
Copilot AI review requested due to automatic review settings May 28, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Defers the is_declare computation in check_method_definition so it only runs for empty-body accessors, avoiding an unnecessary class lookup on the common method path.

Changes:

  • Removed unconditional is_declare calculation at the top of check_method_definition.
  • Inlined the is_declare calculation into the accessor-without-body branch, gated on is_accessor && is_empty_body && !is_abstract.

@codspeed-hq

codspeed-hq Bot commented May 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 57 untouched benchmarks


Comparing c/05-28-perf_semantic_defer_declare_lookup_for_empty_accessors (8c126e8) with main (8422e8b)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (1599f11) during the generation of this report, so 8422e8b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label May 28, 2026

camc314 commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

Only compute whether the containing class is `declare` when checking empty-body TypeScript accessors. Ordinary methods and overload signatures do not need that value, so the hot method path can avoid repeated  containing-class lookups.
@graphite-app graphite-app Bot force-pushed the c/05-28-perf_semantic_defer_declare_lookup_for_empty_accessors branch from 8c126e8 to 9e496a7 Compare May 28, 2026 20:08
@graphite-app graphite-app Bot merged commit 9e496a7 into main May 28, 2026
29 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label May 28, 2026
@graphite-app graphite-app Bot deleted the c/05-28-perf_semantic_defer_declare_lookup_for_empty_accessors branch May 28, 2026 20:14
camc314 pushed a commit that referenced this pull request Jun 1, 2026
### 🚀 Features

- 9c71f2e ast, codegen, formatter: Add `WithClauseKeyword::as_str`
helper and use it (#22791) (camc314)

### 🐛 Bug Fixes

- cf5769c parser: Reject TypeScript declarations in single-statement
context (#22827) (Boshen)
- c360fb6 parser: Reject generators in ambient contexts and overload
signatures (TS1221/TS1222) (#22848) (Boshen)
- cc60d8d parser: Reject invalid index signature parameter types
(TS1268/TS1337) (#22852) (Boshen)
- 3d13e29 parser: Reject `declare` in an already-ambient context
(TS1038) (#22850) (Boshen)
- 5152854 parser: Reject statements in ambient contexts (TS1036)
(#22849) (Boshen)
- 4f9afc5 parser: Reject `export as namespace` inside a namespace body
(TS1316) (#22846) (Boshen)
- 2eafea6 parser: Reject function implementations in ambient contexts
(TS1183) (#22845) (Boshen)
- c645615 parser: Reject incompatible class member modifiers (#22843)
(Boshen)
- 276b78b parser: Reject module-referencing imports/exports in a
namespace body (#22836) (Boshen)
- 842ed1c parser: Parse `class implements` with `implements` as the
class name (#22801) (Boshen)

### ⚡ Performance

- 7e3a567 parser: Reuse cached token kind in delimited-list loops
(#22841) (Boshen)
- 9e741c2 parser: Use peek_token instead of lookahead on the modifier
path (#22842) (Boshen)
- 9e496a7 semantic: Defer declare lookup for empty accessors (#22810)
(camc314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-semantic Area - Semantic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants