-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate logic in logging to avoid allocations where possible
This does two things to try and avoid allocations where possible in logging. 1. Removing a to_string() call on Priority by adding as_str function. 2. Consolidating the extend calls on the buffer into a single call. I've implemented the conversion to string as a private member function to avoid adding to the API surface of Priority. The second allows extend to take advantage of the size_hint generated by the iterator over the slices. Since the length of all of the data is known, flat_map will provide a correct size_hint for the full set of data, providing the reserve call within extend the correctly needed value, and avoiding potentially bumping the capacity multiple times.
- Loading branch information
Showing
1 changed file
with
50 additions
and
10 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