[Extensions] Change EventRouter::Event ctors to use base::StringPiece.
Currently Event's constructors pass the event name by const reference to std::string. However, most call sites pass this parameter using a const char*, which results in a temporary string being constructed. By using base::StringPiece instead, we avoid these temporaries and only create a lightweight object, deferring the construction of the actual string until the Event data member is constructed. I explored passing this parameter by value as a std::string, but that seems trickier, and the general guidance is to use base::StringPiece when possible. Further efficiencies could be gained by auditing call sites where Event instances are constructed and pushing base::StringPiece up through call stacks. Bug: n/a Change-Id: I6931157417172818c59675985dc90b855aca5e87 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4562382 Commit-Queue: Tim <tjudkins@chromium.org> Reviewed-by:Tim <tjudkins@chromium.org> Auto-Submit: David Bertoni <dbertoni@chromium.org> Cr-Commit-Position: refs/heads/main@{#1149235}
Loading
Please register or sign in to comment