Skip to content

Commit

Permalink
optimize Range::split_step(value_type)
Browse files Browse the repository at this point in the history
Summary:
`Range::find()`, in case of `StringPiece` delegates to `memchr`,
use it instead of going through generic `std::find`.

Reviewed By: ot

Differential Revision: D40184614

fbshipit-source-id: a0a22006a572589f10cebc242000075a2d971b22
  • Loading branch information
Philip Pronin authored and facebook-github-bot committed Oct 8, 2022
1 parent 243bced commit 5b6eb44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions folly/Range.h
Original file line number Diff line number Diff line change
Expand Up @@ -1059,10 +1059,10 @@ class Range {
* @author: Marcelo Juchem <[email protected]>
*/
Range split_step(value_type delimiter) {
auto i = std::find(b_, e_, delimiter);
Range result(b_, i);
auto i = find(delimiter);
Range result(b_, i == std::string::npos ? size() : i);

b_ = i == e_ ? e_ : std::next(i);
b_ = result.end() == e_ ? e_ : std::next(result.end());

return result;
}
Expand Down

0 comments on commit 5b6eb44

Please sign in to comment.