Commit 93a63643 authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Don't copy ColumnMap in CSVPassword

CSVPassword represents a credential stored in one CSV line. For
parsing the CSV line, CSVPassword needs to understand the meaning of
columns, which it does through a ColumnMap -- a map from column
indices to column types. Currently, CSVPassword stores its own copy of
the map.

This map is the same for all lines in a single CSV blob. Sharing this
single map among all CSVPassword instances avoids many copies of the
map.

Therefore this CL changes CSVPassword to keep a reference to the map.

Bug: 934326
Change-Id: Id52e3db26fa1fd804f987103bf62e295102f2ce8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1698401
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Auto-Submit: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681888}
parent 366e8d57
...@@ -17,8 +17,8 @@ namespace password_manager { ...@@ -17,8 +17,8 @@ namespace password_manager {
using ::autofill::PasswordForm; using ::autofill::PasswordForm;
CSVPassword::CSVPassword(ColumnMap map, base::StringPiece csv_row) CSVPassword::CSVPassword(const ColumnMap& map, base::StringPiece csv_row)
: map_(std::move(map)), row_(csv_row) {} : map_(map), row_(csv_row) {}
CSVPassword::~CSVPassword() = default; CSVPassword::~CSVPassword() = default;
......
...@@ -24,7 +24,7 @@ class CSVPassword { ...@@ -24,7 +24,7 @@ class CSVPassword {
// Number of values in the Label enum. // Number of values in the Label enum.
static constexpr size_t kLabelCount = 3; static constexpr size_t kLabelCount = 3;
CSVPassword(ColumnMap map, base::StringPiece csv_row); CSVPassword(const ColumnMap& map, base::StringPiece csv_row);
CSVPassword(const CSVPassword&) = delete; CSVPassword(const CSVPassword&) = delete;
CSVPassword(CSVPassword&&) = delete; CSVPassword(CSVPassword&&) = delete;
CSVPassword& operator=(const CSVPassword&) = delete; CSVPassword& operator=(const CSVPassword&) = delete;
...@@ -45,7 +45,7 @@ class CSVPassword { ...@@ -45,7 +45,7 @@ class CSVPassword {
// operator=(). // operator=().
// |map_| stores the meaning of particular columns in the row. // |map_| stores the meaning of particular columns in the row.
ColumnMap map_; const ColumnMap& map_;
// |row_| contains the CSV row from which the PasswordForm is parsed. // |row_| contains the CSV row from which the PasswordForm is parsed.
base::StringPiece row_; base::StringPiece row_;
}; };
......
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