Skip to content

Commit

Permalink
avoid clang-tidy issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishj committed Oct 26, 2023
1 parent c584eb9 commit 1463eb5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/catalog/catalog_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EntryDropper {
}

~EntryDropper() {
entry_index.GetEntry().deleted = old_deleted;
entry_index.GetEntry<true>().deleted = old_deleted;
}

private:
Expand Down
7 changes: 6 additions & 1 deletion src/include/duckdb/catalog/catalog_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ struct EntryValue {
Swap(other);
return *this;
}
template <bool UNSAFE = false>
CatalogEntry &Entry() {
return *entry;
if (UNSAFE) {
return *entry.get();
} else {
return *entry;
}
}
unique_ptr<CatalogEntry> TakeEntry() {
return std::move(entry);
Expand Down
10 changes: 7 additions & 3 deletions src/include/duckdb/catalog/mapping_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,22 @@ struct EntryIndex {
}

private:
template <bool UNSAFE = false>
EntryValue &GetEntryInternal(catalog_entry_t index) {
auto entry = catalog->entries.find(index);
if (entry == catalog->entries.end()) {
if (UNSAFE) {
D_ASSERT(entry != catalog->entries.end());
} else if (entry == catalog->entries.end()) {
throw InternalException("EntryIndex - Catalog entry not found!?");
}
return entry->second;
}

public:
template <bool UNSAFE = false>
CatalogEntry &GetEntry() {
auto &entry_value = GetEntryInternal(index);
return entry_value.Entry();
auto &entry_value = GetEntryInternal<UNSAFE>(index);
return entry_value.template Entry<UNSAFE>();
}
unique_ptr<CatalogEntry> TakeEntry() {
auto &entry_value = GetEntryInternal(index);
Expand Down

0 comments on commit 1463eb5

Please sign in to comment.