refactorings

This commit is contained in:
2022-01-02 17:52:32 +01:00
parent 35cba3b0c4
commit f95080606c
10 changed files with 46 additions and 44 deletions

View File

@@ -183,7 +183,7 @@ void Table::commit_row(Row &row) {
try {
validate_row(row);
index_row(row);
} catch (Exception &e) {
} catch (const Exception &e) {
throw e;
}
}
@@ -250,9 +250,9 @@ void Table::create_index(const Index& index) {
bool Table::drop_index(const std::string &index_name) {
auto it = std::find_if(m_indexes.begin(), m_indexes.end(),
[&index_name](const Index &idx) {
return idx.get_index_name() == index_name;
});
[&index_name](const Index &idx) {
return idx.get_index_name() == index_name;
});
if (it != m_indexes.end()) {
m_indexes.erase(it);
@@ -317,24 +317,25 @@ void Table::index_rows(const std::string &index_name) {
Index * Table::get_index(const std::string &index_name) {
auto it = std::find_if(m_indexes.begin(), m_indexes.end(),
[&index_name](const Index &idx) {
return idx.get_index_name() == index_name;
});
[&index_name](const Index &idx) {
return idx.get_index_name() == index_name;
});
return (it != m_indexes.end()) ? &(*it) : nullptr;
}
Index * Table::get_index_for_column(const std::string &col_name) {
auto it = std::find_if(m_indexes.begin(), m_indexes.end(),
[&col_name](const Index &idx) {
return idx.get_column_name() == col_name;
});
[&col_name](const Index &idx) {
return idx.get_column_name() == col_name;
});
return (it != m_indexes.end()) ? &(*it) : nullptr;
}
bool Table::empty() {
bool Table::empty() const {
if (m_rows.empty()) return true;
for (const auto & r : m_rows)
if (r.is_visible()) return false;