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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(ws): optimize message handler lookup #13378

Merged

Conversation

CodyTseng
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

Each WebSocket request requires iterating through all message handlers to find the appropriate one now. When there are many message handlers, this is much less efficient than using a Map for lookup.

What is the new behavior?

Using a Map for message handler lookup instead of traversing an array.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4f50b2b4-f390-4601-a1d4-4d83c3c20299

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.123%

Totals Coverage Status
Change from base Build eacd3e56-4bed-4f5e-9bab-412a10335aab: 0.0%
Covered Lines: 6736
Relevant Lines: 7312

💛 - Coveralls

@CodyTseng CodyTseng marked this pull request as ready for review March 31, 2024 09:46
@kamilmysliwiec kamilmysliwiec merged commit e5c439d into nestjs:master Aug 12, 2024
5 checks passed
@kamilmysliwiec
Copy link
Member

lgtm

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

Successfully merging this pull request may close these issues.

6 participants