Skip to content
Open
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
10 changes: 9 additions & 1 deletion src/template_db/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ inline void Nonsynced_Transaction::flush()
}


inline bool ends_with(const std::string& s, const std::string& suffix)
{
return s.size() >= suffix.size() && s.compare(s.size() - suffix.size(), suffix.size(), suffix) == 0;
}


inline File_Blocks_Index_Base* Nonsynced_Transaction::data_index
(const File_Properties* fp)
{
Expand All @@ -108,7 +114,9 @@ inline File_Blocks_Index_Base* Nonsynced_Transaction::data_index
File_Blocks_Index_Base* data_index = fp->new_data_index(access_mode, use_shadow, db_dir, file_name_extension);
if (data_index != 0)
{
if (access_mode == Access_Mode::readonly)
// Statements of a union read the same skeleton and local tag blocks, but look up different
// tags in the global tag index, so its blocks are rarely read again: don't cache them.
if (access_mode == Access_Mode::readonly && !ends_with(fp->get_file_name_trunk(), "_tags_global"))
data_index->block_cache = &block_cache_;
data_files[fp] = data_index;
}
Expand Down