Skip to content
Commit 856d235d authored by David Bertoni's avatar David Bertoni Committed by Chromium LUCI CQ
Browse files

[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: default avatarTim <tjudkins@chromium.org>
Auto-Submit: David Bertoni <dbertoni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1149235}
parent 3cb19ba2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment