8000 [core] Improve `HttpStatus.forStatus` by using map lookup by Petersoj · Pull Request #2368 · javalin/javalin · GitHub
[go: up one dir, main page]

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

[core] Improve HttpStatus.forStatus by using map lookup #2368

Merged
merged 2 commits into from
Mar 2, 2025

Conversation

Petersoj
Copy link
Contributor
@Petersoj Petersoj commented Feb 4, 2025

The current HttpStatus.forStatus implementation appears to be a brute force search:

fun forStatus(status: Int): HttpStatus =
HttpStatus.entries.find { it.code == status } ?: UNKNOWN

This PR changes the HttpStatus.forStatus implementation to use a map lookup, similar to HandlerType.findByName.

Copy link
codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.13%. Comparing base (2b63b76) to head (f27e462).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2368   +/-   ##
=========================================
  Coverage     87.12%   87.13%           
  Complexity     1320     1320           
=========================================
  Files           148      148           
  Lines          4467     4468    +1     
  Branches        512      512           
=========================================
+ Hits           3892     3893    +1     
  Misses          354      354           
  Partials        221      221           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tipsy
Copy link
Member
tipsy commented Mar 2, 2025

Thanks @Petersoj, and thanks @dzikoysk for reviewing !

@tipsy tipsy merged commit 5d36221 into javalin:master Mar 2, 2025
15 checks passed
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.

3 participants
0