Commit a2b84111 authored by George Burgess IV's avatar George Burgess IV Committed by Commit Bot

ui: use a StringPiece instead of std::string

The strings stored in `tokens` all have static storage duration, so
there's no reason to put them in `std::string`s.

AX-Relnotes: n/a.

Bug: None
Change-Id: I9b6bc9e847e5c27d68707a4f33d37b225ded34fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2457589Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Commit-Queue: George Burgess <gbiv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817317}
parent fd886ff8
......@@ -6,6 +6,7 @@
#include <vector>
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
namespace ui {
......@@ -15,13 +16,13 @@ std::ostream& operator<<(std::ostream& stream, const AXMode& mode) {
}
std::string AXMode::ToString() const {
std::vector<std::string> tokens;
std::vector<base::StringPiece> tokens;
// Written as a loop with a switch so that this crashes if a new
// mode flag is added without adding support for logging it.
for (uint32_t mode_flag = AXMode::kFirstModeFlag;
mode_flag <= AXMode::kLastModeFlag; mode_flag = mode_flag << 1) {
const char* flag_name = nullptr;
base::StringPiece flag_name;
switch (mode_flag) {
case AXMode::kNativeAPIs:
flag_name = "kNativeAPIs";
......@@ -46,7 +47,7 @@ std::string AXMode::ToString() const {
break;
}
DCHECK(flag_name);
DCHECK(!flag_name.empty());
if (has_mode(mode_flag))
tokens.push_back(flag_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment