sway icon indicating copy to clipboard operation
sway copied to clipboard

Update `analyze_expressions` to take an Iterator instead of Vec

Open JoshuaBatty opened this issue 1 year ago • 7 comments

Description

The means we no longer have to unnecessarily construct a vector and can just pass an iterator. This was suggested in the recent trail of bits report.

Checklist

  • [ ] I have linked to any relevant issues.
  • [ ] I have commented my code, particularly in hard-to-understand areas.
  • [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • [ ] I have added tests that prove my fix is effective or that my feature works.
  • [ ] I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • [ ] I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • [ ] I have requested a review from the relevant team or maintainers.

JoshuaBatty avatar May 01 '24 01:05 JoshuaBatty

Benchmark for 926e4e7

Click to view benchmark
Test Base PR %
code_action 5.5±0.03ms 5.4±0.09ms -1.82%
code_lens 298.4±6.46ns 338.6±10.72ns +13.47%
compile 6.5±0.12s 6.4±0.06s -1.54%
completion 4.8±0.15ms 4.9±0.09ms +2.08%
did_change_with_caching 6.4±0.07s 6.4±0.04s 0.00%
document_symbol 927.8±13.21µs 953.8±21.20µs +2.80%
format 89.0±1.42ms 88.0±1.25ms -1.12%
goto_definition 367.6±7.34µs 381.7±46.41µs +3.84%
highlight 8.7±0.26ms 8.8±0.20ms +1.15%
hover 605.9±17.33µs 616.1±13.54µs +1.68%
idents_at_position 124.5±1.31µs 127.1±2.76µs +2.09%
inlay_hints 656.3±26.22µs 660.0±37.83µs +0.56%
on_enter 473.0±4.07ns 480.4±10.40ns +1.56%
parent_decl_at_position 3.6±0.02ms 3.6±0.05ms 0.00%
prepare_rename 370.2±5.30µs 434.6±5.89µs +17.40%
rename 9.3±0.06ms 9.2±0.05ms -1.08%
semantic_tokens 1046.2±17.35µs 1051.2±15.16µs +0.48%
token_at_position 365.7±2.64µs 368.5±3.01µs +0.77%
tokens_at_position 3.6±0.02ms 3.6±0.16ms 0.00%
tokens_for_file 430.1±3.25µs 428.0±2.23µs -0.49%
traverse 54.9±2.70ms 54.9±2.05ms 0.00%

github-actions[bot] avatar May 01 '24 01:05 github-actions[bot]

Benchmark for e0786c6

Click to view benchmark
Test Base PR %
code_action 5.4±0.12ms 5.4±0.18ms 0.00%
code_lens 289.5±7.69ns 335.8±4.97ns +15.99%
compile 6.3±0.06s 6.3±0.07s 0.00%
completion 4.8±0.12ms 4.9±0.09ms +2.08%
did_change_with_caching 6.2±0.06s 6.3±0.09s +1.61%
document_symbol 1003.1±33.39µs 944.9±14.01µs -5.80%
format 87.1±0.71ms 88.9±1.50ms +2.07%
goto_definition 364.6±4.01µs 376.4±14.31µs +3.24%
highlight 8.8±0.26ms 8.8±0.16ms 0.00%
hover 607.5±19.11µs 614.8±17.06µs +1.20%
idents_at_position 122.4±0.65µs 123.0±1.10µs +0.49%
inlay_hints 652.8±22.66µs 661.8±32.39µs +1.38%
on_enter 481.3±8.90ns 497.5±11.36ns +3.37%
parent_decl_at_position 3.6±0.02ms 3.6±0.05ms 0.00%
prepare_rename 378.9±3.88µs 366.6±8.45µs -3.25%
rename 9.3±0.26ms 9.3±0.03ms 0.00%
semantic_tokens 1015.0±16.86µs 1025.1±15.32µs +1.00%
token_at_position 359.3±3.04µs 363.4±1.75µs +1.14%
tokens_at_position 3.6±0.02ms 3.6±0.04ms 0.00%
tokens_for_file 429.3±5.48µs 427.2±9.63µs -0.49%
traverse 50.6±1.53ms 50.6±1.66ms 0.00%

github-actions[bot] avatar May 01 '24 10:05 github-actions[bot]

Benchmark for b669a9b

Click to view benchmark
Test Base PR %
code_action 5.4±0.25ms 5.4±0.04ms 0.00%
code_lens 338.4±14.43ns 290.2±7.76ns -14.24%
compile 6.3±0.05s 6.5±0.09s +3.17%
completion 5.0±0.25ms 5.2±0.24ms +4.00%
did_change_with_caching 6.4±0.12s 6.4±0.08s 0.00%
document_symbol 983.9±52.28µs 941.5±26.27µs -4.31%
format 87.5±1.26ms 87.0±2.06ms -0.57%
goto_definition 359.7±5.62µs 367.2±3.51µs +2.09%
highlight 8.8±0.19ms 8.8±0.22ms 0.00%
hover 607.0±22.99µs 601.1±29.38µs -0.97%
idents_at_position 123.9±0.34µs 123.6±1.30µs -0.24%
inlay_hints 654.4±50.81µs 654.7±29.63µs +0.05%
on_enter 485.6±14.49ns 501.4±12.40ns +3.25%
parent_decl_at_position 3.6±0.05ms 3.6±0.05ms 0.00%
prepare_rename 358.4±6.52µs 363.9±7.94µs +1.53%
rename 9.3±0.08ms 9.5±0.34ms +2.15%
semantic_tokens 1008.8±25.31µs 1022.8±11.16µs +1.39%
token_at_position 352.0±2.65µs 362.4±2.38µs +2.95%
tokens_at_position 3.6±0.16ms 3.6±0.04ms 0.00%
tokens_for_file 430.4±3.99µs 421.8±11.07µs -2.00%
traverse 52.5±0.86ms 51.2±1.37ms -2.48%

github-actions[bot] avatar May 01 '24 12:05 github-actions[bot]

Benchmark for 11e674d

Click to view benchmark
Test Base PR %
code_action 5.3±0.03ms 5.4±0.10ms +1.89%
code_lens 340.6±14.06ns 291.9±12.74ns -14.30%
compile 6.4±0.06s 6.4±0.03s 0.00%
completion 4.8±0.05ms 4.8±0.08ms 0.00%
did_change_with_caching 6.4±0.09s 6.4±0.09s 0.00%
document_symbol 966.1±43.64µs 1004.6±33.03µs +3.99%
format 88.6±0.83ms 87.8±1.40ms -0.90%
goto_definition 359.5±7.85µs 367.6±5.89µs +2.25%
highlight 8.8±0.23ms 8.7±0.15ms -1.14%
hover 610.1±10.61µs 608.6±10.57µs -0.25%
idents_at_position 124.2±0.37µs 123.4±1.47µs -0.64%
inlay_hints 648.2±23.71µs 709.4±22.76µs +9.44%
on_enter 483.0±19.93ns 508.7±58.29ns +5.32%
parent_decl_at_position 3.6±0.03ms 3.6±0.06ms 0.00%
prepare_rename 364.2±7.72µs 365.7±9.54µs +0.41%
rename 9.3±0.06ms 9.3±0.23ms 0.00%
semantic_tokens 1020.5±21.86µs 1021.8±17.99µs +0.13%
token_at_position 357.9±5.06µs 362.9±10.69µs +1.40%
tokens_at_position 3.6±0.05ms 3.6±0.09ms 0.00%
tokens_for_file 431.6±3.99µs 427.8±3.04µs -0.88%
traverse 52.9±2.57ms 51.7±1.51ms -2.27%

github-actions[bot] avatar May 01 '24 21:05 github-actions[bot]

Benchmark for 61e3007

Click to view benchmark
Test Base PR %
code_action 5.5±0.11ms 5.6±0.18ms +1.82%
code_lens 287.0±4.80ns 303.5±10.41ns +5.75%
compile 6.7±0.11s 6.6±0.15s -1.49%
completion 4.9±0.12ms 4.9±0.10ms 0.00%
did_change_with_caching 6.6±0.10s 6.7±0.09s +1.52%
document_symbol 940.5±34.43µs 976.3±66.05µs +3.81%
format 88.6±4.14ms 87.5±0.52ms -1.24%
goto_definition 359.3±9.55µs 365.6±8.52µs +1.75%
highlight 9.0±0.17ms 8.7±0.26ms -3.33%
hover 600.0±18.82µs 607.4±13.42µs +1.23%
idents_at_position 123.1±1.64µs 122.8±1.83µs -0.24%
inlay_hints 668.6±14.80µs 659.0±29.11µs -1.44%
on_enter 491.6±14.96ns 501.2±15.10ns +1.95%
parent_decl_at_position 3.7±0.06ms 3.6±0.04ms -2.70%
prepare_rename 367.3±13.62µs 362.5±7.54µs -1.31%
rename 9.7±0.20ms 9.5±0.23ms -2.06%
semantic_tokens 1006.3±23.65µs 1037.9±28.98µs +3.14%
token_at_position 351.3±12.36µs 353.2±2.61µs +0.54%
tokens_at_position 4.1±0.32ms 3.6±0.09ms -12.20%
tokens_for_file 424.8±4.55µs 420.2±1.99µs -1.08%
traverse 52.4±3.39ms 52.0±2.30ms -0.76%

github-actions[bot] avatar May 02 '24 10:05 github-actions[bot]

Benchmark for d371f2c

Click to view benchmark
Test Base PR %
code_action 5.5±0.10ms 5.3±0.10ms -3.64%
code_lens 287.7±6.82ns 288.6±7.59ns +0.31%
compile 6.2±0.02s 6.2±0.04s 0.00%
completion 4.9±0.02ms 4.8±0.12ms -2.04%
did_change_with_caching 6.2±0.09s 6.2±0.09s 0.00%
document_symbol 1012.3±46.32µs 961.8±32.40µs -4.99%
format 88.7±1.24ms 87.9±1.28ms -0.90%
goto_definition 377.4±5.90µs 371.4±4.88µs -1.59%
highlight 9.0±0.23ms 8.7±0.14ms -3.33%
hover 617.6±15.11µs 616.9±53.31µs -0.11%
idents_at_position 122.6±0.27µs 123.3±1.80µs +0.57%
inlay_hints 658.7±14.31µs 662.3±7.68µs +0.55%
on_enter 490.9±17.64ns 488.7±12.92ns -0.45%
parent_decl_at_position 3.7±0.03ms 3.6±0.02ms -2.70%
prepare_rename 370.3±7.66µs 370.3±5.76µs 0.00%
rename 9.5±0.12ms 9.2±0.21ms -3.16%
semantic_tokens 1058.0±27.01µs 1040.3±21.85µs -1.67%
token_at_position 366.9±5.05µs 365.2±2.67µs -0.46%
tokens_at_position 3.7±0.08ms 3.6±0.02ms -2.70%
tokens_for_file 423.0±2.62µs 421.7±10.71µs -0.31%
traverse 50.4±2.02ms 50.7±2.34ms +0.60%

github-actions[bot] avatar May 03 '24 00:05 github-actions[bot]

Benchmark for 04f7c7c

Click to view benchmark
Test Base PR %
code_action 5.5±0.12ms 5.3±0.08ms -3.64%
code_lens 292.5±5.83ns 290.4±7.10ns -0.72%
compile 6.2±0.03s 6.3±0.05s +1.61%
completion 4.9±0.03ms 4.8±0.03ms -2.04%
did_change_with_caching 6.3±0.06s 6.2±0.06s -1.59%
document_symbol 932.2±25.11µs 1019.9±36.44µs +9.41%
format 90.7±1.77ms 87.4±1.21ms -3.64%
goto_definition 359.7±7.23µs 371.6±27.25µs +3.31%
highlight 9.0±0.30ms 8.7±0.19ms -3.33%
hover 607.9±34.67µs 614.7±16.88µs +1.12%
idents_at_position 123.2±0.51µs 124.1±2.06µs +0.73%
inlay_hints 665.0±11.80µs 659.6±28.09µs -0.81%
on_enter 491.4±21.54ns 491.9±8.73ns +0.10%
parent_decl_at_position 3.7±0.03ms 3.6±0.03ms -2.70%
prepare_rename 357.8±7.55µs 367.4±7.36µs +2.68%
rename 9.5±0.19ms 9.2±0.28ms -3.16%
semantic_tokens 1038.5±15.45µs 1096.1±38.64µs +5.55%
token_at_position 353.2±1.40µs 367.9±2.84µs +4.16%
tokens_at_position 3.7±0.04ms 3.6±0.07ms -2.70%
tokens_for_file 419.3±3.36µs 424.0±2.54µs +1.12%
traverse 51.4±2.81ms 51.6±2.65ms +0.39%

github-actions[bot] avatar May 03 '24 23:05 github-actions[bot]

this was addressed in #5945

JoshuaBatty avatar May 06 '24 10:05 JoshuaBatty