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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

vlib, tools: make minor improvements #19950

Merged
merged 8 commits into from Nov 21, 2023
Merged

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Nov 20, 2023

This PR contains some accumulated changes. Cleaning stashes, I thought they can be grouped in a PR with minor improvements.
E.g.,

  • preferring to do less expensive checks in if conditions first
  • using a const instead of re-assigning arrays with static data in often called fns
  • preferring a match statement where it can promote readability
  • using loops with a predefined end if the loop logic allows for it

馃[deprecated] Generated by Copilot at aa560c2

This pull request improves the code quality, performance, and readability of various modules in the v compiler and tools, such as vdoc, vvet, checker, parser, and comptime. It mainly involves reordering, simplifying, or removing some if statements, using match statements, and fixing typos and formatting issues. It also affects the html generation of vdoc by escaping script tags in markdown comments.

馃[deprecated] Generated by Copilot at aa560c2

  • Simplify and refactor the logic of escaping html tags in comments and collecting submodules prefixes for the navigation bar in cmd/tools/vdoc/html.v (link, link, link)
  • Remove the unused markdown_escape_script_tags function from cmd/tools/vdoc/markdown.v (link)
  • Move the term_colors constant from cmd/tools/vvet/vvet.v to cmd/tools/vdoc/html.v and add a new constant clean_seq to clean the tags from the comments (link, link)
  • Simplify the retry logic for the ssl_do, http_do, and proxy.http_do methods in vlib/net/http/request.v by using range-based for loops instead of manual counters and while loops (link, link, link)
  • Swap the order of the conditions in several if statements in vlib/v/checker/checker.v, vlib/v/checker/errors.v, vlib/v/checker/fn.v, vlib/v/checker/struct.v, vlib/v/parser/comptime.v, and vlib/v/parser/expr.v to make them more consistent and avoid unnecessary checks (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Refactor the logic of registering the variables for the comptime for loop in vlib/v/parser/comptime.v by using a match statement instead of multiple if statements (link)
  • Refactor the logic of setting the module name based on the language in vlib/v/parser/parser.v by using a match statement instead of multiple if statements (link)

@ttytm ttytm marked this pull request as draft November 20, 2023 17:09
@ttytm ttytm force-pushed the misc/perf-refactor branch 2 times, most recently from 9d1acf6 to 39ad28a Compare November 20, 2023 17:15
@ttytm ttytm marked this pull request as ready for review November 20, 2023 17:18
cmd/tools/vdoc/html.v Outdated Show resolved Hide resolved
cmd/tools/vdoc/html.v Outdated Show resolved Hide resolved
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Good work.

@spytheman spytheman merged commit 09ed7d7 into vlang:master Nov 21, 2023
54 checks passed
@ttytm ttytm deleted the misc/perf-refactor branch December 15, 2023 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants