Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions google/cloud/bigtable/examples/table_admin_snippets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ void DropRowsByPrefix(
}

void WaitForConsistencyCheck(
google::cloud::bigtable_admin::BigtableTableAdminClient admin,
google::cloud::bigtable_admin::BigtableTableAdminClient const& admin,
std::vector<std::string> const& argv) {
//! [wait for consistency check]
namespace cbt = ::google::cloud::bigtable;
Expand All @@ -631,7 +631,7 @@ void WaitForConsistencyCheck(
using ::google::cloud::future;
using ::google::cloud::Status;
using ::google::cloud::StatusOr;
[](cbta::BigtableTableAdminClient, std::string const& project_id,
[](cbta::BigtableTableAdminClient const&, std::string const& project_id,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The passed-in client is ignored here, and a new one is created on line 636. This is inefficient as it requires establishing a new connection. It would be better to use the passed-in client.

To fix this, WaitForConsistencyCheck should take its admin parameter by value (reverting the change on line 625). Then, this lambda could also take admin by value, and use it instead of creating a new client. This would make the code more efficient and consistent with other snippets in this file.

std::string const& instance_id, std::string const& table_id) {
auto client = cbta::BigtableTableAdminClient(
cbta::MakeBigtableTableAdminConnection());
Expand Down
Loading