-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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
Refactor Core Functions for Clarity and Performance #6093
Conversation
…dability - Removed unnecessary variable `fn` and directly returned query parser functions - Used template literals for error message for consistency with modern syntax
…ability - Replaced multiple `if` conditions with `switch` for clearer type handling - Simplified boolean function return and direct array handling in `proxyaddr.compile` - Ensured support for empty/default cases with a default return
- Replaced function declaration with arrow function - Separated ternary condition into multiple lines for clarity - Changed `var` to `const` for better scoping and modern standards
- Improved variable declarations using const and let - Simplified parameter parsing with destructuring - Ensured the return structure remains consistent
- Use const for length and let for loop variable - Initialize result array with specific length for better performance - Maintain functionality while enhancing code readability
- Replaced indexOf() with includes() for clarity and improved readability. - Maintained original functionality while streamlining the code.
- Removed unnecessary variable declaration for function assignment. - Simplified return statements for false and valid cases. - Improved error message formatting using template literals.
… handling - Updated debug message to use template literals for improved readability. - Removed the explicit error variable in the catch statement for cleaner syntax.
… conciseness - Replaced var with const and let for variable declarations. - Used optional chaining for file existence checks. - Simplified logic by removing intermediate variable assignments. - Added an explicit return of undefined if no valid file is found.
- Used const for variable declaration to enhance readability. - Replaced conditional logic with startsWith() for cleaner extension validation. - Added comments for clarity on functionality.
- Simplified argument handling by using Array.from() for flattened arguments. - Used const for variable declaration to enhance readability.
…ved readability" This reverts commit ef96e84.
Hey @Ayoub-Mabrouk! Thanks for this PR, can you run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main issue with this PR is that it does too much at once. I think we would likely accept a most of this if it was done in separate PRs with clear and small individual changes.
I would work on making sure each section of change is done in an individual PR and that PR has a clear description of why refactoring that section is helpful. Also, if we are going to discuss "for performance" we need some benchmarks. It is fine if we think it will improve perf in theory, and we might still land them because of that, but if that is the case I think we should just avoid calling it "perf" until we have those benchmarks.
hey @wesleytodd Thanks for the feedback! I’ll create separate PRs with smaller, targeted improvements, each with a clear description of the refactoring benefits. |
Thanks for split this into multiple PRs ❤️ ! I added a reference on the description of each PR so now we can follow it better and enabled the CI too. I will close this PR now 😉 |
This pull request includes several refactorings to improve code clarity, conciseness, and performance:
Refactored Functions:
req.is
,app.engine
,View.prototype.resolve
, andtryStat
for better readability.Optimizations:
includes()
innormalizeType
.normalizeTypes
with better variable declarations and array initialization.Modern Syntax:
acceptParams
and improvedcreateETagGenerator
.Cleaner Logic:
compileQueryParser
.These changes enhance maintainability while preserving functionality.