Skip to content

Use more explicit operations in core helpers (and other nits) #58873

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

Merged
merged 16 commits into from
Jun 18, 2024

Conversation

DanielRosenwasser
Copy link
Member

@DanielRosenwasser DanielRosenwasser commented Jun 15, 2024

This PR takes care of a few nits in the codebase, including:

  • Using ?? over || when possible.
  • Using numeric for loops in core.ts for all iteration over arrays.
  • Using explicit checks for undefined on core.ts helpers.
  • Use compound assignment operators when possible.

Many of these are rooted in the need for core utilities to be faster, and therefore use fewer implicit operations like iterator usage, truthiness, etc.

There are some other things I noticed, but this seemed like a reasonable first pass.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jun 15, 2024
@DanielRosenwasser
Copy link
Member Author

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 15, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this ✅ Started 👀 Results

@DanielRosenwasser DanielRosenwasser marked this pull request as ready for review June 15, 2024 01:11
@typescript-bot
Copy link
Collaborator

@DanielRosenwasser
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 194,558k (± 0.95%) 193,412k (± 0.95%) ~ 192,092k 195,811k p=0.575 n=6
Parse Time 1.57s (± 1.49%) 1.56s (± 1.32%) ~ 1.53s 1.58s p=0.864 n=6
Bind Time 0.86s (± 1.40%) 0.85s (± 0.48%) -0.02s (- 1.74%) 0.84s 0.85s p=0.025 n=6
Check Time 11.22s (± 0.28%) 11.17s (± 0.30%) -0.05s (- 0.46%) 11.14s 11.23s p=0.029 n=6
Emit Time 3.25s (± 1.62%) 3.27s (± 1.08%) ~ 3.20s 3.30s p=0.191 n=6
Total Time 16.90s (± 0.37%) 16.85s (± 0.42%) ~ 16.73s 16.95s p=0.421 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,104 944,104 ~ ~ ~ p=1.000 n=6
Types 407,044 407,044 ~ ~ ~ p=1.000 n=6
Memory used 1,218,258k (± 0.00%) 1,218,299k (± 0.00%) ~ 1,218,217k 1,218,357k p=0.230 n=6
Parse Time 7.95s (± 0.19%) 7.92s (± 0.58%) ~ 7.84s 7.97s p=0.292 n=6
Bind Time 2.23s (± 0.63%) 2.23s (± 0.77%) ~ 2.20s 2.25s p=1.000 n=6
Check Time 35.86s (± 0.29%) 35.85s (± 0.36%) ~ 35.71s 36.02s p=1.000 n=6
Emit Time 16.20s (± 0.65%) 16.20s (± 0.38%) ~ 16.11s 16.26s p=1.000 n=6
Total Time 62.24s (± 0.22%) 62.19s (± 0.26%) ~ 61.98s 62.38s p=0.748 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 2,132,311 2,132,311 ~ ~ ~ p=1.000 n=6
Types 926,040 926,040 ~ ~ ~ p=1.000 n=6
Memory used 2,115,402k (± 0.01%) 2,115,449k (± 0.01%) ~ 2,115,215k 2,115,587k p=0.689 n=6
Parse Time 9.70s (± 0.38%) 9.69s (± 0.12%) ~ 9.67s 9.70s p=0.935 n=6
Bind Time 3.39s (± 0.43%) 3.37s (± 1.05%) ~ 3.33s 3.42s p=0.334 n=6
Check Time 103.11s (± 0.33%) 102.96s (± 0.40%) ~ 102.53s 103.51s p=0.521 n=6
Emit Time 0.20s (± 3.73%) 0.20s (± 4.47%) ~ 0.19s 0.21s p=0.798 n=6
Total Time 116.40s (± 0.29%) 116.22s (± 0.37%) ~ 115.75s 116.81s p=0.471 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,230,955 1,230,613 -342 (- 0.03%) ~ ~ p=0.001 n=6
Types 261,256 261,204 -52 (- 0.02%) ~ ~ p=0.001 n=6
Memory used 2,346,033k (± 0.02%) 2,355,356k (± 1.04%) ~ 2,343,080k 2,405,476k p=0.810 n=6
Parse Time 5.94s (± 0.43%) 5.96s (± 0.77%) ~ 5.92s 6.04s p=0.810 n=6
Bind Time 2.26s (± 0.63%) 2.26s (± 0.78%) ~ 2.23s 2.27s p=0.809 n=6
Check Time 39.95s (± 0.26%) 39.77s (± 0.47%) ~ 39.63s 40.14s p=0.066 n=6
Emit Time 3.19s (± 3.49%) 3.19s (± 3.28%) ~ 3.07s 3.35s p=0.936 n=6
Total Time 51.35s (± 0.33%) 51.17s (± 0.64%) ~ 50.90s 51.80s p=0.093 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,230,955 1,230,613 -342 (- 0.03%) ~ ~ p=0.001 n=6
Types 261,256 261,204 -52 (- 0.02%) ~ ~ p=0.001 n=6
Memory used 2,422,863k (± 0.04%) 2,422,523k (± 0.04%) ~ 2,421,283k 2,423,992k p=0.471 n=6
Parse Time 6.24s (± 0.86%) 6.25s (± 0.78%) ~ 6.18s 6.31s p=0.810 n=6
Bind Time 2.01s (± 1.07%) 2.02s (± 0.40%) ~ 2.01s 2.03s p=0.513 n=6
Check Time 40.30s (± 0.20%) 40.10s (± 0.24%) -0.20s (- 0.51%) 39.99s 40.22s p=0.013 n=6
Emit Time 3.15s (± 2.80%) 3.17s (± 2.25%) ~ 3.05s 3.23s p=0.378 n=6
Total Time 51.74s (± 0.32%) 51.55s (± 0.26%) ~ 51.42s 51.77s p=0.066 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,666 258,594 -72 (- 0.03%) ~ ~ p=0.001 n=6
Types 104,900 104,829 -71 (- 0.07%) ~ ~ p=0.001 n=6
Memory used 428,258k (± 0.01%) 428,220k (± 0.01%) -38k (- 0.01%) 428,194k 428,259k p=0.037 n=6
Parse Time 3.30s (± 0.54%) 3.33s (± 1.03%) ~ 3.30s 3.39s p=0.073 n=6
Bind Time 1.29s (± 0.58%) 1.30s (± 1.25%) ~ 1.28s 1.32s p=0.216 n=6
Check Time 17.85s (± 0.41%) 17.68s (± 0.39%) -0.17s (- 0.97%) 17.60s 17.76s p=0.013 n=6
Emit Time 1.37s (± 1.81%) 1.38s (± 1.02%) ~ 1.36s 1.40s p=0.462 n=6
Total Time 23.81s (± 0.31%) 23.69s (± 0.33%) -0.12s (- 0.49%) 23.62s 23.83s p=0.045 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,734 ~ ~ ~ p=1.000 n=6
Memory used 369,494k (± 0.03%) 369,425k (± 0.01%) ~ 369,366k 369,483k p=0.298 n=6
Parse Time 2.77s (± 0.64%) 2.78s (± 1.10%) ~ 2.74s 2.81s p=0.256 n=6
Bind Time 1.60s (± 1.04%) 1.59s (± 1.05%) ~ 1.58s 1.62s p=0.240 n=6
Check Time 15.48s (± 0.30%) 15.48s (± 0.27%) ~ 15.41s 15.52s p=0.685 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.85s (± 0.25%) 19.86s (± 0.27%) ~ 19.78s 19.94s p=0.936 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,859,742 2,859,742 ~ ~ ~ p=1.000 n=6
Types 969,532 969,532 ~ ~ ~ p=1.000 n=6
Memory used 3,024,838k (± 0.00%) 3,024,846k (± 0.00%) ~ 3,024,772k 3,024,940k p=0.936 n=6
Parse Time 16.66s (± 0.31%) 16.59s (± 0.17%) -0.07s (- 0.39%) 16.56s 16.64s p=0.037 n=6
Bind Time 5.08s (± 0.21%) 5.07s (± 0.39%) ~ 5.05s 5.10s p=0.217 n=6
Check Time 88.42s (± 0.32%) 88.55s (± 0.42%) ~ 88.18s 89.20s p=0.810 n=6
Emit Time 29.19s (± 0.56%) 29.09s (± 0.54%) ~ 28.89s 29.33s p=0.336 n=6
Total Time 139.33s (± 0.26%) 139.30s (± 0.36%) ~ 138.78s 140.18s p=0.630 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 266,914 266,914 ~ ~ ~ p=1.000 n=6
Types 108,685 108,685 ~ ~ ~ p=1.000 n=6
Memory used 411,278k (± 0.02%) 411,321k (± 0.02%) ~ 411,238k 411,509k p=0.689 n=6
Parse Time 3.79s (± 0.32%) 3.79s (± 0.27%) ~ 3.77s 3.80s p=0.408 n=6
Bind Time 1.68s (± 0.31%) 1.68s (± 0.58%) ~ 1.67s 1.69s p=0.348 n=6
Check Time 16.82s (± 0.34%) 16.83s (± 0.38%) ~ 16.74s 16.94s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.30s (± 0.24%) 22.30s (± 0.29%) ~ 22.20s 22.40s p=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 523,429 523,429 ~ ~ ~ p=1.000 n=6
Types 177,955 177,955 ~ ~ ~ p=1.000 n=6
Memory used 461,632k (± 0.06%) 461,809k (± 0.01%) ~ 461,696k 461,855k p=0.128 n=6
Parse Time 2.64s (± 0.52%) 2.63s (± 0.57%) ~ 2.62s 2.66s p=0.453 n=6
Bind Time 0.99s (± 0.64%) 0.99s ~ ~ ~ p=1.000 n=6
Check Time 15.27s (± 0.53%) 15.20s (± 0.34%) ~ 15.15s 15.29s p=0.127 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 18.89s (± 0.41%) 18.82s (± 0.23%) ~ 18.77s 18.89s p=0.092 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,284ms (± 0.97%) 2,274ms (± 0.52%) ~ 2,262ms 2,295ms p=0.518 n=6
Req 2 - geterr 5,056ms (± 0.34%) 5,038ms (± 0.52%) ~ 5,006ms 5,083ms p=0.298 n=6
Req 3 - references 265ms (± 1.06%) 265ms (± 0.40%) ~ 263ms 266ms p=0.167 n=6
Req 4 - navto 229ms (± 0.53%) 228ms (± 0.43%) ~ 226ms 229ms p=0.340 n=6
Req 5 - completionInfo count 1,357 1,357 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 87ms (± 3.88%) 87ms (± 2.81%) ~ 82ms 88ms p=0.235 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,391ms (± 0.40%) 2,396ms (± 0.86%) ~ 2,370ms 2,431ms p=0.873 n=6
Req 2 - geterr 3,803ms (± 0.55%) 3,795ms (± 0.12%) ~ 3,790ms 3,802ms p=0.173 n=6
Req 3 - references 277ms (± 0.53%) 275ms (± 0.32%) -2ms (- 0.78%) 274ms 276ms p=0.028 n=6
Req 4 - navto 227ms (± 0.28%) 227ms (± 0.23%) ~ 226ms 227ms p=0.386 n=6
Req 5 - completionInfo count 1,519 1,519 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 74ms (± 8.45%) 69ms (± 3.59%) ~ 67ms 74ms p=0.142 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen 5,137ms (± 0.35%) 5,168ms (± 0.20%) +31ms (+ 0.61%) 5,159ms 5,184ms p=0.020 n=6
Req 2 - geterr 1,130ms (± 1.83%) 1,121ms (± 0.31%) ~ 1,115ms 1,124ms p=0.630 n=6
Req 3 - references 80ms (± 5.08%) 76ms (± 1.53%) ~ 75ms 78ms p=0.061 n=6
Req 4 - navto 454ms (± 1.16%) 454ms (± 0.84%) ~ 448ms 458ms p=0.685 n=6
Req 5 - completionInfo count 3,413 3,413 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 835ms (± 1.16%) 837ms (± 1.41%) ~ 822ms 850ms p=0.809 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 157.52ms (± 0.17%) 157.57ms (± 0.16%) +0.05ms (+ 0.03%) 156.44ms 159.40ms p=0.029 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 241.18ms (± 0.14%) 241.17ms (± 0.15%) ~ 239.69ms 248.38ms p=0.795 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 236.55ms (± 0.15%) 236.57ms (± 0.17%) ~ 235.19ms 246.95ms p=0.668 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 236.51ms (± 0.16%) 236.30ms (± 0.16%) -0.21ms (- 0.09%) 234.77ms 240.75ms p=0.000 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@jakebailey
Copy link
Member

@typescript-bot perf test this faster predictable [email protected]

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 17, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this faster predictable [email protected] ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v22.3.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 193,991k 193,973k -18k (- 0.01%) ~ ~ p=0.001 n=6
Parse Time 1.78s 1.78s (± 0.31%) ~ 1.77s 1.78s p=0.071 n=6
Bind Time 0.90s 0.90s ~ ~ ~ p=1.000 n=6
Check Time 10.51s (± 0.04%) 10.46s (± 0.06%) -0.05s (- 0.46%) 10.45s 10.47s p=0.003 n=6
Emit Time 3.47s 3.46s (± 0.12%) -0.01s (- 0.24%) 3.46s 3.47s p=0.007 n=6
Total Time 16.65s (± 0.03%) 16.60s (± 0.03%) -0.06s (- 0.34%) 16.59s 16.60s p=0.004 n=6
angular-1 - node (v22.3.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,104 944,104 ~ ~ ~ p=1.000 n=6
Types 407,044 407,044 ~ ~ ~ p=1.000 n=6
Memory used 1,221,201k (± 0.00%) 1,221,071k -130k (- 0.01%) ~ ~ p=0.002 n=6
Parse Time 7.86s (± 0.10%) 7.71s (± 0.05%) -0.15s (- 1.87%) 7.71s 7.72s p=0.003 n=6
Bind Time 2.19s (± 0.19%) 2.18s -0.01s (- 0.38%) ~ ~ p=0.007 n=6
Check Time 32.59s (± 0.06%) 32.24s (± 0.13%) -0.35s (- 1.08%) 32.18s 32.29s p=0.005 n=6
Emit Time 14.06s (± 0.13%) 14.06s (± 0.21%) ~ 14.00s 14.08s p=1.000 n=6
Total Time 56.70s (± 0.04%) 56.19s (± 0.09%) -0.51s (- 0.90%) 56.12s 56.25s p=0.005 n=6
mui-docs - node (v22.3.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,132,326 2,132,326 ~ ~ ~ p=1.000 n=6
Types 926,744 926,744 ~ ~ ~ p=1.000 n=6
Memory used 2,120,751k (± 0.00%) 2,120,792k (± 0.00%) +41k (+ 0.00%) 2,120,789k 2,120,806k p=0.003 n=6
Parse Time 7.43s (± 0.05%) 7.38s (± 0.06%) -0.05s (- 0.72%) 7.37s 7.38s p=0.003 n=6
Bind Time 2.29s 2.30s (± 0.22%) +0.01s (+ 0.29%) 2.29s 2.30s p=0.025 n=6
Check Time 74.00s (± 0.11%) 74.30s (± 0.41%) ~ 73.80s 74.64s p=0.065 n=6
Emit Time 0.15s 0.14s (± 2.88%) 🟩-0.01s (- 5.56%) 0.14s 0.15s p=0.007 n=6
Total Time 83.87s (± 0.10%) 84.12s (± 0.36%) ~ 83.62s 84.46s p=0.066 n=6
self-build-src - node (v22.3.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,230,955 1,230,613 -342 (- 0.03%) ~ ~ p=0.001 n=6
Types 261,256 261,204 -52 (- 0.02%) ~ ~ p=0.001 n=6
Memory used 2,374,069k (± 0.00%) 2,373,123k (± 0.00%) -945k (- 0.04%) 2,373,122k 2,373,124k p=0.004 n=6
Parse Time 5.82s (± 0.14%) 5.83s (± 0.09%) ~ 5.82s 5.83s p=0.803 n=6
Bind Time 2.15s (± 0.46%) 2.12s (± 0.24%) -0.03s (- 1.47%) 2.11s 2.12s p=0.004 n=6
Check Time 40.11s (± 0.10%) 39.92s (± 0.06%) -0.19s (- 0.48%) 39.88s 39.94s p=0.005 n=6
Emit Time 3.46s (± 0.28%) 3.49s (± 0.43%) +0.03s (+ 0.91%) 3.48s 3.52s p=0.005 n=6
Total Time 51.52s (± 0.09%) 51.36s (± 0.06%) -0.16s (- 0.30%) 51.31s 51.40s p=0.005 n=6
self-build-src-public-api - node (v22.3.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,230,955 1,230,613 -342 (- 0.03%) ~ ~ p=0.001 n=6
Types 261,256 261,204 -52 (- 0.02%) ~ ~ p=0.001 n=6
Memory used 2,455,792k (± 0.00%) 2,455,172k (± 0.00%) -620k (- 0.03%) 2,455,170k 2,455,174k p=0.004 n=6
Parse Time 8.51s (± 0.16%) 8.45s (± 0.12%) -0.06s (- 0.70%) 8.44s 8.46s p=0.004 n=6
Bind Time 3.10s (± 0.39%) 3.11s (± 0.24%) ~ 3.10s 3.12s p=0.062 n=6
Check Time 59.24s (± 0.07%) 58.96s (± 0.09%) -0.28s (- 0.47%) 58.91s 59.05s p=0.005 n=6
Emit Time 5.11s (± 0.20%) 5.13s (± 0.23%) ~ 5.12s 5.15s p=0.059 n=6
Total Time 75.99s (± 0.07%) 75.67s (± 0.07%) -0.31s (- 0.41%) 75.64s 75.77s p=0.005 n=6
self-compiler - node (v22.3.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,666 258,594 -72 (- 0.03%) ~ ~ p=0.001 n=6
Types 104,900 104,829 -71 (- 0.07%) ~ ~ p=0.001 n=6
Memory used 430,101k 430,014k -87k (- 0.02%) ~ ~ p=0.001 n=6
Parse Time 4.16s (± 0.47%) 4.15s (± 0.39%) ~ 4.13s 4.17s p=0.168 n=6
Bind Time 1.72s 1.69s -0.03s (- 1.74%) ~ ~ p=0.001 n=6
Check Time 23.58s (± 0.07%) 23.82s (± 0.10%) +0.24s (+ 1.03%) 23.80s 23.86s p=0.005 n=6
Emit Time 1.89s 1.88s (± 0.22%) -0.01s (- 0.62%) 1.87s 1.88s p=0.002 n=6
Total Time 31.35s (± 0.08%) 31.53s (± 0.07%) +0.18s (+ 0.57%) 31.50s 31.56s p=0.005 n=6
ts-pre-modules - node (v22.3.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,734 ~ ~ ~ p=1.000 n=6
Memory used 371,122k 371,095k -27k (- 0.01%) ~ ~ p=0.001 n=6
Parse Time 3.73s (± 0.41%) 3.72s (± 0.40%) ~ 3.71s 3.74s p=0.315 n=6
Bind Time 1.72s 1.71s -0.01s (- 0.58%) ~ ~ p=0.001 n=6
Check Time 20.10s (± 0.08%) 20.16s (± 0.12%) +0.07s (+ 0.33%) 20.14s 20.20s p=0.005 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 25.55s (± 0.11%) 25.59s (± 0.07%) +0.05s (+ 0.18%) 25.57s 25.62s p=0.015 n=6
vscode - node (v22.3.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,861,290 2,861,290 ~ ~ ~ p=1.000 n=6
Types 969,811 969,811 ~ ~ ~ p=1.000 n=6
Memory used 3,030,745k (± 0.00%) 3,030,669k (± 0.00%) -76k (- 0.00%) 3,030,667k 3,030,672k p=0.003 n=6
Parse Time 16.49s (± 0.13%) 16.43s (± 0.08%) -0.06s (- 0.38%) 16.41s 16.45s p=0.005 n=6
Bind Time 5.49s (± 0.43%) 5.77s (± 0.09%) 🔻+0.29s (+ 5.22%) 5.77s 5.78s p=0.004 n=6
Check Time 101.71s (± 0.19%) 105.25s (± 0.08%) +3.53s (+ 3.47%) 105.15s 105.34s p=0.005 n=6
Emit Time 34.15s (± 0.19%) 33.71s (± 0.27%) -0.44s (- 1.28%) 33.55s 33.80s p=0.005 n=6
Total Time 157.83s (± 0.12%) 161.16s (± 0.07%) +3.32s (+ 2.11%) 161.06s 161.37s p=0.005 n=6
webpack - node (v22.3.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 266,914 266,914 ~ ~ ~ p=1.000 n=6
Types 108,685 108,685 ~ ~ ~ p=1.000 n=6
Memory used 414,456k (± 0.00%) 414,334k (± 0.00%) -121k (- 0.03%) 414,333k 414,341k p=0.003 n=6
Parse Time 4.98s (± 0.18%) 4.94s (± 0.21%) -0.04s (- 0.74%) 4.93s 4.96s p=0.005 n=6
Bind Time 2.20s 2.23s (± 0.18%) +0.03s (+ 1.44%) 2.23s 2.24s p=0.002 n=6
Check Time 23.43s (± 0.14%) 23.20s (± 0.08%) -0.23s (- 0.99%) 23.18s 23.22s p=0.005 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 30.61s (± 0.11%) 30.37s (± 0.08%) -0.23s (- 0.76%) 30.34s 30.41s p=0.005 n=6
xstate-main - node (v22.3.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 523,429 523,429 ~ ~ ~ p=1.000 n=6
Types 177,955 177,955 ~ ~ ~ p=1.000 n=6
Memory used 465,488k 465,492k (± 0.00%) +4k (+ 0.00%) 465,492k 465,494k p=0.002 n=6
Parse Time 4.44s (± 0.26%) 4.43s (± 0.33%) ~ 4.41s 4.45s p=0.142 n=6
Bind Time 1.52s (± 0.27%) 1.51s (± 0.34%) ~ 1.51s 1.52s p=0.112 n=6
Check Time 23.65s (± 0.08%) 23.51s (± 0.10%) -0.14s (- 0.59%) 23.49s 23.54s p=0.005 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 29.61s (± 0.05%) 29.46s (± 0.05%) -0.15s (- 0.51%) 29.44s 29.47s p=0.005 n=6
System info unknown
Hosts
  • node (v22.3.0, x64)
Scenarios
  • Compiler-Unions - node (v22.3.0, x64)
  • angular-1 - node (v22.3.0, x64)
  • mui-docs - node (v22.3.0, x64)
  • self-build-src - node (v22.3.0, x64)
  • self-build-src-public-api - node (v22.3.0, x64)
  • self-compiler - node (v22.3.0, x64)
  • ts-pre-modules - node (v22.3.0, x64)
  • vscode - node (v22.3.0, x64)
  • webpack - node (v22.3.0, x64)
  • xstate-main - node (v22.3.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

Comment on lines 706 to 685
/** @internal */
/** @internal *
Copy link
Member

Choose a reason for hiding this comment

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

The heck is happening here

Copy link
Member Author

Choose a reason for hiding this comment

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

I dunno how that happened, but it is pretty funny that this is never used.

@DanielRosenwasser DanielRosenwasser changed the title Fix various nits in core.ts and elsewhere Use more explicit operations in core helpers (and other nits) Jun 17, 2024
@DanielRosenwasser
Copy link
Member Author

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 17, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this ✅ Started 👀 Results

Comment on lines +1755 to +1756
// NOTE: arrayFrom means that if the callback mutates the underlying collection,
// we won't have an accurate set of values
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// NOTE: arrayFrom means that if the callback mutates the underlying collection,
// we won't have an accurate set of values
// NOTE: arrayFrom prevents `action` from modifying the map while we iterate

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest, I'm not sure if the copy was intentional.

Copy link
Member

Choose a reason for hiding this comment

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

Nothing fails when it's removed, huh

Copy link
Member Author

Choose a reason for hiding this comment

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

Neither behavior is really easy to make guarantees about without extra book-keeping.

Right now if you add a new value and it's added into an array under the hood, you will witness a new value if you're in the middle of iterating, but not if you've already finished iterating over all values with a given key.

On the other hand, if the multimap stores a single value, you'll never see any added values as you iterate.

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 192,122k (± 0.06%) 192,740k (± 0.76%) ~ 192,109k 195,713k p=1.000 n=6
Parse Time 1.97s (± 1.22%) 1.96s (± 1.18%) ~ 1.93s 2.00s p=0.517 n=6
Bind Time 1.07s (± 0.78%) 1.06s (± 1.41%) ~ 1.04s 1.08s p=1.000 n=6
Check Time 13.87s (± 0.45%) 13.81s (± 0.31%) ~ 13.75s 13.87s p=0.090 n=6
Emit Time 4.07s (± 4.40%) 4.02s (± 0.70%) ~ 3.97s 4.05s p=0.517 n=6
Total Time 20.97s (± 0.89%) 20.85s (± 0.19%) ~ 20.80s 20.90s p=0.093 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,114 944,114 ~ ~ ~ p=1.000 n=6
Types 407,051 407,051 ~ ~ ~ p=1.000 n=6
Memory used 1,218,236k (± 0.00%) 1,218,306k (± 0.00%) +69k (+ 0.01%) 1,218,263k 1,218,348k p=0.008 n=6
Parse Time 7.96s (± 0.43%) 7.93s (± 0.57%) ~ 7.87s 7.98s p=0.255 n=6
Bind Time 2.24s (± 1.56%) 2.22s (± 0.49%) ~ 2.21s 2.24s p=0.155 n=6
Check Time 35.82s (± 0.45%) 35.72s (± 0.42%) ~ 35.47s 35.83s p=0.297 n=6
Emit Time 16.18s (± 0.50%) 16.10s (± 0.78%) ~ 15.88s 16.25s p=0.336 n=6
Total Time 62.21s (± 0.27%) 61.98s (± 0.38%) ~ 61.59s 62.25s p=0.065 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,132,310 2,132,310 ~ ~ ~ p=1.000 n=6
Types 926,699 926,699 ~ ~ ~ p=1.000 n=6
Memory used 2,115,161k (± 0.01%) 2,115,209k (± 0.00%) ~ 2,115,083k 2,115,347k p=0.298 n=6
Parse Time 7.85s (± 0.27%) 7.83s (± 0.38%) ~ 7.80s 7.87s p=0.258 n=6
Bind Time 2.75s (± 0.59%) 2.74s (± 0.63%) ~ 2.71s 2.76s p=0.194 n=6
Check Time 83.92s (± 0.44%) 83.43s (± 0.35%) -0.49s (- 0.58%) 82.93s 83.84s p=0.045 n=6
Emit Time 0.16s (± 3.29%) 0.16s (± 2.58%) ~ 0.15s 0.16s p=0.595 n=6
Total Time 94.68s (± 0.37%) 94.16s (± 0.30%) -0.52s (- 0.55%) 93.69s 94.58s p=0.045 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,030 1,230,537 -493 (- 0.04%) ~ ~ p=0.001 n=6
Types 261,267 261,138 -129 (- 0.05%) ~ ~ p=0.001 n=6
Memory used 2,346,515k (± 0.04%) 2,356,006k (± 1.02%) ~ 2,345,354k 2,404,902k p=1.000 n=6
Parse Time 5.99s (± 0.89%) 5.98s (± 0.98%) ~ 5.90s 6.07s p=0.872 n=6
Bind Time 2.26s (± 0.36%) 2.27s (± 0.79%) ~ 2.24s 2.29s p=0.219 n=6
Check Time 39.88s (± 0.14%) 39.82s (± 0.20%) ~ 39.68s 39.93s p=0.335 n=6
Emit Time 3.18s (± 3.01%) 3.17s (± 1.41%) ~ 3.10s 3.22s p=0.575 n=6
Total Time 51.32s (± 0.17%) 51.26s (± 0.14%) ~ 51.17s 51.35s p=0.298 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,030 1,230,537 -493 (- 0.04%) ~ ~ p=0.001 n=6
Types 261,267 261,138 -129 (- 0.05%) ~ ~ p=0.001 n=6
Memory used 2,421,842k (± 0.02%) 2,421,042k (± 0.04%) ~ 2,420,175k 2,422,353k p=0.173 n=6
Parse Time 5.16s (± 0.75%) 5.22s (± 1.46%) ~ 5.09s 5.31s p=0.128 n=6
Bind Time 1.70s (± 0.94%) 1.69s (± 0.71%) ~ 1.68s 1.71s p=0.618 n=6
Check Time 34.34s (± 0.22%) 34.05s (± 0.15%) -0.29s (- 0.83%) 33.99s 34.11s p=0.005 n=6
Emit Time 2.69s (± 2.50%) 2.76s (± 2.35%) ~ 2.67s 2.84s p=0.077 n=6
Total Time 43.93s (± 0.31%) 43.76s (± 0.21%) ~ 43.63s 43.90s p=0.066 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,677 258,567 -110 (- 0.04%) ~ ~ p=0.001 n=6
Types 104,901 104,819 -82 (- 0.08%) ~ ~ p=0.001 n=6
Memory used 428,274k (± 0.01%) 428,153k (± 0.01%) -121k (- 0.03%) 428,112k 428,188k p=0.005 n=6
Parse Time 4.12s (± 0.84%) 4.11s (± 0.74%) ~ 4.07s 4.14s p=0.685 n=6
Bind Time 1.61s (± 1.98%) 1.60s (± 1.15%) ~ 1.58s 1.63s p=0.462 n=6
Check Time 22.16s (± 0.29%) 21.91s (± 0.42%) -0.25s (- 1.14%) 21.75s 22.02s p=0.005 n=6
Emit Time 1.72s (± 1.93%) 1.72s (± 1.74%) ~ 1.68s 1.77s p=0.935 n=6
Total Time 29.61s (± 0.15%) 29.34s (± 0.31%) -0.27s (- 0.93%) 29.17s 29.43s p=0.005 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,734 ~ ~ ~ p=1.000 n=6
Memory used 369,469k (± 0.03%) 369,463k (± 0.02%) ~ 369,327k 369,565k p=0.936 n=6
Parse Time 2.77s (± 1.13%) 2.78s (± 0.75%) ~ 2.75s 2.80s p=0.418 n=6
Bind Time 1.60s (± 0.94%) 1.59s (± 0.56%) ~ 1.58s 1.60s p=0.445 n=6
Check Time 15.52s (± 0.46%) 15.44s (± 0.41%) ~ 15.35s 15.50s p=0.126 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.89s (± 0.31%) 19.81s (± 0.29%) ~ 19.71s 19.88s p=0.054 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,861,834 2,861,834 ~ ~ ~ p=1.000 n=6
Types 969,859 969,859 ~ ~ ~ p=1.000 n=6
Memory used 3,025,750k (± 0.00%) 3,025,728k (± 0.00%) ~ 3,025,632k 3,025,809k p=0.810 n=6
Parse Time 16.67s (± 0.19%) 16.56s (± 0.76%) ~ 16.47s 16.81s p=0.065 n=6
Bind Time 5.01s (± 0.47%) 5.00s (± 0.20%) ~ 4.98s 5.01s p=0.252 n=6
Check Time 88.08s (± 0.35%) 87.87s (± 0.33%) ~ 87.62s 88.34s p=0.230 n=6
Emit Time 29.09s (± 0.86%) 28.86s (± 0.53%) ~ 28.69s 29.09s p=0.126 n=6
Total Time 138.85s (± 0.23%) 138.30s (± 0.21%) -0.55s (- 0.40%) 137.86s 138.71s p=0.020 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 266,914 266,914 ~ ~ ~ p=1.000 n=6
Types 108,685 108,685 ~ ~ ~ p=1.000 n=6
Memory used 411,299k (± 0.01%) 411,324k (± 0.01%) ~ 411,271k 411,372k p=0.471 n=6
Parse Time 3.80s (± 0.56%) 3.80s (± 0.35%) ~ 3.79s 3.82s p=0.804 n=6
Bind Time 1.68s (± 0.90%) 1.68s (± 0.53%) ~ 1.67s 1.69s p=0.458 n=6
Check Time 16.84s (± 0.45%) 16.83s (± 0.40%) ~ 16.72s 16.90s p=0.872 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.33s (± 0.39%) 22.31s (± 0.32%) ~ 22.18s 22.37s p=0.809 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 523,694 523,694 ~ ~ ~ p=1.000 n=6
Types 178,007 178,007 ~ ~ ~ p=1.000 n=6
Memory used 461,630k (± 0.07%) 461,760k (± 0.08%) ~ 461,307k 462,059k p=0.689 n=6
Parse Time 3.91s (± 0.66%) 3.91s (± 0.51%) ~ 3.89s 3.94s p=0.685 n=6
Bind Time 1.48s (± 0.85%) 1.47s (± 1.58%) ~ 1.43s 1.50s p=0.370 n=6
Check Time 22.37s (± 0.77%) 22.24s (± 0.41%) ~ 22.10s 22.33s p=0.229 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.76s (± 0.57%) 27.62s (± 0.26%) ~ 27.51s 27.69s p=0.148 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,971ms (±11.12%) 3,392ms (± 0.59%) ~ 3,356ms 3,410ms p=0.093 n=6
Req 2 - geterr 6,890ms (± 9.89%) 7,512ms (± 0.63%) 🔻+622ms (+ 9.03%) 7,452ms 7,559ms p=0.013 n=6
Req 3 - references 399ms (± 0.16%) 396ms (± 0.34%) -3ms (- 0.84%) 394ms 398ms p=0.005 n=6
Req 4 - navto 341ms (± 0.12%) 340ms (± 0.49%) ~ 337ms 342ms p=0.101 n=6
Req 5 - completionInfo count 1,357 1,357 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 132ms (± 1.17%) 128ms (± 4.48%) 🟩-5ms (- 3.41%) 116ms 131ms p=0.021 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 3,601ms (± 0.76%) 3,563ms (± 0.65%) -38ms (- 1.05%) 3,528ms 3,585ms p=0.031 n=6
Req 2 - geterr 5,555ms (± 0.78%) 5,542ms (± 0.79%) ~ 5,481ms 5,605ms p=0.575 n=6
Req 3 - references 417ms (± 0.33%) 414ms (± 0.36%) -3ms (- 0.64%) 412ms 415ms p=0.022 n=6
Req 4 - navto 339ms (± 1.04%) 337ms (± 0.72%) ~ 335ms 342ms p=0.139 n=6
Req 5 - completionInfo count 1,519 1,519 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 112ms (± 5.59%) 102ms (± 1.01%) 🟩-11ms (- 9.50%) 100ms 103ms p=0.004 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen 6,135ms (± 0.42%) 6,322ms (± 4.96%) +187ms (+ 3.05%) 6,152ms 6,961ms p=0.008 n=6
Req 2 - geterr 1,709ms (± 0.90%) 1,579ms (± 9.97%) 🟩-129ms (- 7.57%) 1,374ms 1,699ms p=0.020 n=6
Req 3 - references 121ms (± 3.36%) 112ms (± 1.13%) 🟩-9ms (- 7.69%) 111ms 114ms p=0.007 n=6
Req 4 - navto 593ms (± 2.33%) 586ms (± 1.39%) ~ 578ms 600ms p=0.376 n=6
Req 5 - completionInfo count 3,413 3,413 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 1,271ms (± 2.23%) 1,232ms (± 1.18%) 🟩-39ms (- 3.08%) 1,211ms 1,249ms p=0.030 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 228.63ms (± 0.19%) 228.64ms (± 0.18%) ~ 226.56ms 231.51ms p=0.847 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 294.71ms (± 0.27%) 294.64ms (± 0.28%) -0.08ms (- 0.03%) 287.37ms 300.12ms p=0.027 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 288.72ms (± 0.27%) 288.63ms (± 0.27%) -0.08ms (- 0.03%) 281.83ms 294.79ms p=0.014 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 348.97ms (± 0.29%) 348.97ms (± 0.30%) ~ 341.13ms 357.83ms p=0.935 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@@ -2145,6 +2120,14 @@ export function compareTextSpans(a: Partial<TextSpan> | undefined, b: Partial<Te
return compareValues(a?.start, b?.start) || compareValues(a?.length, b?.length);
}

/** @internal */
export function maxBy<T>(arr: readonly T[], init: number, mapper: (x: T) => number): number {
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess this could always be a reduceMapped instead.

@DanielRosenwasser DanielRosenwasser merged commit 4935e14 into main Jun 18, 2024
28 checks passed
@DanielRosenwasser DanielRosenwasser deleted the danielNits20240614 branch June 18, 2024 23:00
export function arraysEqual<T>(a: readonly T[], b: readonly T[], equalityComparer: EqualityComparer<T> = equateValues): boolean {
return a.length === b.length && a.every((x, i) => equalityComparer(x, b[i]));
}

/** @internal */
export function indexOfAnyCharCode(text: string, charCodes: readonly number[], start?: number): number {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this function is ever called in a hot path it would probably be more efficient to convert charCodes to a Set first to reduce the O(text*codes) to O(text)

if (!some(array2)) return array1;
if (!some(array1)) return array2;
if (array2 === undefined || array2.length === 0) return array1;
if (array1 === undefined || array1.length === 0) return array2;
return [...array1, ...array2];
Copy link
Contributor

Choose a reason for hiding this comment

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

if indexed array access is significantly faster via avoiding iterator semantics, using array1.concat(array2) is probably faster for the same reason.

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +881 to 886
if (result ?? !v) {
result ??= array.slice(0, i);
if (v) {
result.push(v);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be more readable as:

Suggested change
if (result ?? !v) {
result ??= array.slice(0, i);
if (v) {
result.push(v);
}
}
if (v) {
// If result has been initialized it is looking to collect truthy values separately.
// Otherwise it will be initialized when we hit our first falsy value.
result?.push(v);
} else {
// If this is our first falsy value, copy over the current stretch of truthy values.
result ??= array.slice(0, i);
}

Comment on lines 1684 to 1685
if (!multiMap.has(hash)) return false;
const candidates = multiMap.get(hash)!;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this utility function expressly support undefined being a meaningful value in the set? Otherwise this would be more efficient to call get and do a check against undefined instead of calling into the map twice.

@@ -305,7 +306,7 @@ function createTabularErrorsDisplay(filesInError: (ReportFileInError | undefined

const numberLength = (num: number) => Math.log(num) * Math.LOG10E + 1;
const fileToErrorCount = distinctFiles.map(file => ([file, countWhere(filesInError, fileInError => fileInError!.fileName === file!.fileName)] as const));
const maxErrors = fileToErrorCount.reduce((acc, value) => Math.max(acc, value[1] || 0), 0);
const maxErrors = maxBy(fileToErrorCount, 0, value => value[1]);

const headerRow = Diagnostics.Errors_Files.message;
const leftColumnHeadingLength = headerRow.split(" ")[0].length;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const leftColumnHeadingLength = headerRow.split(" ")[0].length;
const leftColumnFirstSpace = headerRow.indexOf(" ");
const leftColumnHeadingLength = leftColumnFirstSpace < 0 ? headerRow.length : leftColumnFirstSpace;

Though I assume this line isn't a hot path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants