Skip to content

Commit

Permalink
Expand folly::split documentation examples
Browse files Browse the repository at this point in the history
Summary:
Documentation is likely a second (after code usage  in the codebase) if not the
first one source of usage examples. Let's expand it a little bit by adding more
usage examples:
* there is a difference between char (' ') and string (" ") delimiter
  performance wise.
* `folly::small_vector` and `folly::StringPiece` might be used to avoid heap
  allocation if number of split pieces are know in advance.

Reviewed By: IosifSpulber

Differential Revision: D50009704

fbshipit-source-id: 1b42102523b2a9a228e16ccb1115044463d9dcaa
  • Loading branch information
ilvokhin authored and facebook-github-bot committed Oct 17, 2023
1 parent 1cf9ac0 commit b518be8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions folly/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,13 @@ struct IsSimdSupportedDelim<char> : std::true_type {};
* Examples:
*
* std::vector<folly::StringPiece> v;
* folly::split(":", "asd:bsd", v);
* folly::split(':', "asd:bsd", v);
*
* folly::small_vector<folly::StringPiece, 3> v;
* folly::split(':', "asd:bsd:csd", v)
*
* std::set<StringPiece> s;
* folly::splitTo<StringPiece>(":", "asd:bsd:asd:csd",
* folly::splitTo<StringPiece>("::", "asd::bsd::asd::csd",
* std::inserter(s, s.begin()));
*
* Split also takes a flag (ignoreEmpty) that indicates whether adjacent
Expand Down

0 comments on commit b518be8

Please sign in to comment.