Skip to content

Optimize and improve request module #51

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lvitals
Copy link

@lvitals lvitals commented Apr 9, 2025

Performance Improvements:

  • Cached frequently used functions and methods
  • Optimized string operations
  • Reduced unnecessary table creations

Code Quality:

  • Centralized regex patterns as constants
  • Improved error handling
  • Added safety checks for edge cases
  • Reduced code duplication
  • Standardized code formatting

Maintainability:

  • Better code organization
  • More consistent style
  • Clearer separation of concerns

- Cache frequently used functions for better performance
- Centralize regex patterns in constants
- Add better error handling and edge case protection
- Improve code organization and readability
- Reduce code duplication
- Add more safety checks
- Standardize code formatting
- Optimize string operations
@tomasguisasola
Copy link
Member

Have you tested the code? I think I found some mistakes:

  1. At line 121, the variable _ in your code is a global, but it was a local in the original;
  2. At line 158, you could also use a constant for the pattern (just a suggestion);
  3. Also at line 158, you should not use %- when using string.find with true as the fourth value, since it turns off the pattern matching facilities (the same occurs at line 160);
  4. At lines 159, 161 and 163, the new call input(length) is not the same as the original wsapi_env.input:read(length), since the first argument (wsapi_env.input) is absent: you might correct that!
  5. You also make a different metatable, although with the same content, for each :new call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants