-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce allocations in per-request methods to improve performance (#395)
* Prevent additional allocations when sorting routes for selection Use of an uninitialized array and the use of sort.Reverse cause extra allocations in request routing which are unnecessary. * Reduce allocations in Accept and Content-Type matching The mime handling methods can do a single pass over the header without needing to allocate. This improves performance of these methods in higher traffic API servers. * Reduce allocations in route selection The use of new arrays for each phase of detectRoute can be simplified: each pass filters the existing array and whatever is left at the end is returned. While somewhat harder to read, this method is a significant source of allocations.
- Loading branch information
1 parent
e64cccd
commit 8673ba5
Showing
4 changed files
with
68 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters