Skip to content

Commit

Permalink
Fix AutoInitCopy #2
Browse files Browse the repository at this point in the history
Summary: Missed a few in earlier fixes for AutoInitCopy rule. Also added a few fixes for anoymous class rule and local shadowing rule.

Reviewed By: luqun

Differential Revision: D15467213

fbshipit-source-id: 0b17073
  • Loading branch information
yizhang82 authored and facebook-github-bot committed Dec 23, 2019
1 parent 4cd8178 commit b1fb095
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 28 deletions.
2 changes: 1 addition & 1 deletion storage/rocksdb/event_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static std::vector<Rdb_index_stats> extract_index_stats(
const std::vector<std::string> &files,
const rocksdb::TablePropertiesCollection &props) {
std::vector<Rdb_index_stats> ret;
for (auto fn : files) {
for (const auto &fn : files) {
const auto it = props.find(fn);
DBUG_ASSERT(it != props.end());
std::vector<Rdb_index_stats> stats;
Expand Down
16 changes: 6 additions & 10 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3518,8 +3518,6 @@ static Rdb_transaction *&get_tx_from_thd(THD *const thd) {
my_core::thd_ha_data(thd, rocksdb_hton));
}

namespace {

class Rdb_perf_context_guard {
Rdb_io_perf m_io_perf;
Rdb_io_perf *m_io_perf_ptr;
Expand Down Expand Up @@ -3555,8 +3553,6 @@ class Rdb_perf_context_guard {
}
};

} // anonymous namespace

/*
TODO: maybe, call this in external_lock() and store in ha_rocksdb..
*/
Expand Down Expand Up @@ -4665,12 +4661,12 @@ static bool rocksdb_rollback_to_savepoint_can_release_mdl(
*/
static void rocksdb_update_table_stats(
/* per-table stats callback */
void (*cb)(const char *db, const char *tbl, bool is_partition,
my_io_perf_t *r, my_io_perf_t *w, my_io_perf_t *r_blob,
my_io_perf_t *r_primary, my_io_perf_t *r_secondary,
page_stats_t *page_stats, comp_stats_t *comp_stats,
int n_lock_wait, int n_lock_wait_timeout, int n_lock_deadlock,
const char *engine)) {
void (*cb)(const char *_db, const char *_tbl, bool _is_partition,
my_io_perf_t *_r, my_io_perf_t *w, my_io_perf_t *_r_blob,
my_io_perf_t *_r_primary, my_io_perf_t *_r_secondary,
page_stats_t *_page_stats, comp_stats_t *_comp_stats,
int _n_lock_wait, int _n_lock_wait_timeout, int _n_lock_deadlock,
const char *_engine)) {
my_io_perf_t io_perf_read;
my_io_perf_t io_perf_write;
my_io_perf_t io_perf;
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/properties_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ rocksdb::UserCollectedProperties Rdb_tbl_prop_coll::GetReadableProperties()
s.append(" records...]");
#else
bool first = true;
for (auto it : m_stats) {
for (const auto &it : m_stats) {
if (first) {
first = false;
} else {
Expand Down
8 changes: 6 additions & 2 deletions storage/rocksdb/rdb_cf_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void Rdb_cf_manager::init(
}

void Rdb_cf_manager::cleanup() {
for (auto it : m_cf_name_map) {
for (const auto &it : m_cf_name_map) {
delete it.second;
}
mysql_mutex_destroy(&m_mutex);
Expand Down Expand Up @@ -166,7 +166,7 @@ std::vector<std::string> Rdb_cf_manager::get_cf_names(void) const {
std::vector<std::string> names;

RDB_MUTEX_LOCK_CHECK(m_mutex);
for (auto it : m_cf_name_map) {
for (const auto &it : m_cf_name_map) {
names.push_back(it.first);
}
RDB_MUTEX_UNLOCK_CHECK(m_mutex);
Expand All @@ -190,6 +190,8 @@ std::vector<rocksdb::ColumnFamilyHandle *> Rdb_cf_manager::get_all_cf(
return list;
}

namespace {

struct Rdb_cf_scanner : public Rdb_tables_scanner {
uint32_t m_cf_id;
int m_is_cf_used;
Expand All @@ -212,6 +214,8 @@ struct Rdb_cf_scanner : public Rdb_tables_scanner {
}
};

} // namespace

int Rdb_cf_manager::drop_cf(const std::string &cf_name) {
auto ddl_manager = rdb_get_ddl_manager();
uint32_t cf_id = 0;
Expand Down
26 changes: 16 additions & 10 deletions storage/rocksdb/rdb_datadic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2969,6 +2969,8 @@ int Rdb_key_def::unpack_simple(Rdb_field_packing *const fpi,
// See Rdb_charset_space_info::spaces_xfrm
const int RDB_SPACE_XFRM_SIZE = 32;

namespace {

// A class holding information about how space character is represented in a
// charset.
class Rdb_charset_space_info {
Expand All @@ -2989,6 +2991,8 @@ class Rdb_charset_space_info {
size_t space_mb_len;
};

} // namespace

static std::array<std::unique_ptr<Rdb_charset_space_info>, MY_ALL_CHARSETS_SIZE>
rdb_mem_comparable_space;

Expand Down Expand Up @@ -4162,7 +4166,7 @@ std::shared_ptr<const Rdb_key_def> Rdb_ddl_manager::safe_find(

mysql_rwlock_rdlock(&m_rwlock);

auto it = m_index_num_to_keydef.find(gl_index_id);
const auto it = m_index_num_to_keydef.find(gl_index_id);
if (it != m_index_num_to_keydef.end()) {
const auto table_def = find(it->second.first, false);
if (table_def && it->second.second < table_def->m_key_count) {
Expand All @@ -4172,9 +4176,10 @@ std::shared_ptr<const Rdb_key_def> Rdb_ddl_manager::safe_find(
}
}
} else {
auto it = m_index_num_to_uncommitted_keydef.find(gl_index_id);
if (it != m_index_num_to_uncommitted_keydef.end()) {
const auto &kd = it->second;
const auto uncommitted_it =
m_index_num_to_uncommitted_keydef.find(gl_index_id);
if (uncommitted_it != m_index_num_to_uncommitted_keydef.end()) {
const auto &kd = uncommitted_it->second;
if (kd->max_storage_fmt_length() != 0) {
ret = kd;
}
Expand All @@ -4189,18 +4194,19 @@ std::shared_ptr<const Rdb_key_def> Rdb_ddl_manager::safe_find(
// this method assumes at least read-only lock on m_rwlock
const std::shared_ptr<Rdb_key_def> &Rdb_ddl_manager::find(
GL_INDEX_ID gl_index_id) {
auto it = m_index_num_to_keydef.find(gl_index_id);
const auto it = m_index_num_to_keydef.find(gl_index_id);
if (it != m_index_num_to_keydef.end()) {
auto table_def = find(it->second.first, false);
const auto table_def = find(it->second.first, false);
if (table_def) {
if (it->second.second < table_def->m_key_count) {
return table_def->m_key_descr_arr[it->second.second];
}
}
} else {
auto it = m_index_num_to_uncommitted_keydef.find(gl_index_id);
if (it != m_index_num_to_uncommitted_keydef.end()) {
return it->second;
const auto uncommitted_it =
m_index_num_to_uncommitted_keydef.find(gl_index_id);
if (uncommitted_it != m_index_num_to_uncommitted_keydef.end()) {
return uncommitted_it->second;
}
}

Expand All @@ -4226,7 +4232,7 @@ const std::string Rdb_ddl_manager::safe_get_table_name(
void Rdb_ddl_manager::set_stats(
const std::unordered_map<GL_INDEX_ID, Rdb_index_stats> &stats) {
mysql_rwlock_wrlock(&m_rwlock);
for (auto src : stats) {
for (const auto &src : stats) {
const auto &keydef = find(src.second.m_gl_index_id);
if (keydef) {
keydef->m_stats = src.second;
Expand Down
4 changes: 2 additions & 2 deletions storage/rocksdb/rdb_i_s.cc
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static int rdb_i_s_cfoptions_fill_table(
std::vector<std::string> table_options =
split_into_vector(opts.table_factory->GetPrintableTableOptions(), '\n');

for (auto option : table_options) {
for (std::string option : table_options) {
option.erase(std::remove(option.begin(), option.end(), ' '),
option.end());

Expand Down Expand Up @@ -839,7 +839,7 @@ static int rdb_i_s_compact_stats_fill_table(

Rdb_cf_manager &cf_manager = rdb_get_cf_manager();

for (auto cf_name : cf_manager.get_cf_names()) {
for (const auto &cf_name : cf_manager.get_cf_names()) {
rocksdb::ColumnFamilyHandle *cfh = cf_manager.get_cf(cf_name);

if (cfh == nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/rdb_sst_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ Rdb_sst_info::Rdb_sst_info(rocksdb::DB *const db, const std::string &tablename,
Rdb_sst_info::~Rdb_sst_info() {
DBUG_ASSERT(m_sst_file == nullptr);

for (auto sst_file : m_committed_files) {
for (const auto &sst_file : m_committed_files) {
// In case something went wrong attempt to delete the temporary file.
// If everything went fine that file will have been renamed and this
// function call will fail.
Expand Down
2 changes: 1 addition & 1 deletion storage/rocksdb/rdb_sst_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class Rdb_sst_info {

void reset() {
if (!m_committed) {
for (auto sst_file : m_committed_files) {
for (const auto &sst_file : m_committed_files) {
// In case something went wrong attempt to delete the temporary file.
// If everything went fine that file will have been renamed and this
// function call will fail.
Expand Down

0 comments on commit b1fb095

Please sign in to comment.