mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
Eliminate history_collection_t
This was a pretty useless type.
This commit is contained in:
parent
3d63a68dd0
commit
6e143bf50f
1 changed files with 7 additions and 23 deletions
|
@ -210,16 +210,6 @@ class history_lru_cache_t : public lru_cache_t<history_lru_cache_t, history_lru_
|
|||
}
|
||||
};
|
||||
|
||||
// The set of histories
|
||||
// Note that histories are currently immortal
|
||||
class history_collection_t {
|
||||
owning_lock<std::map<wcstring, std::unique_ptr<history_t>>> histories;
|
||||
|
||||
public:
|
||||
history_t &get_creating(const wcstring &name);
|
||||
void save();
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// history_file_contents_t holds the read-only contents of a file.
|
||||
|
@ -332,7 +322,8 @@ class history_file_contents_t {
|
|||
}
|
||||
};
|
||||
|
||||
static history_collection_t histories;
|
||||
/// The set of all histories.
|
||||
static owning_lock<std::map<wcstring, std::unique_ptr<history_t>>> s_histories;
|
||||
|
||||
static wcstring history_filename(const wcstring &name, const wcstring &suffix);
|
||||
|
||||
|
@ -816,11 +807,11 @@ static size_t offset_of_next_item(const history_file_contents_t &contents, size_
|
|||
return size_t(-1);
|
||||
}
|
||||
|
||||
history_t &history_collection_t::get_creating(const wcstring &name) {
|
||||
history_t &history_t::history_with_name(const wcstring &name) {
|
||||
// Return a history for the given name, creating it if necessary
|
||||
// Note that histories are currently never deleted, so we can return a reference to them without
|
||||
// using something like shared_ptr
|
||||
auto hs = histories.acquire();
|
||||
auto hs = s_histories.acquire();
|
||||
std::unique_ptr<history_t> &hist = (*hs)[name];
|
||||
if (!hist) {
|
||||
hist = make_unique<history_t>(name);
|
||||
|
@ -828,10 +819,6 @@ history_t &history_collection_t::get_creating(const wcstring &name) {
|
|||
return *hist;
|
||||
}
|
||||
|
||||
history_t &history_t::history_with_name(const wcstring &name) {
|
||||
return histories.get_creating(name);
|
||||
}
|
||||
|
||||
history_t::history_t(wcstring pname)
|
||||
: name(std::move(pname)), history_file_id(kInvalidFileID), boundary_timestamp(time(NULL)) {}
|
||||
|
||||
|
@ -1850,16 +1837,13 @@ void history_t::incorporate_external_changes() {
|
|||
}
|
||||
}
|
||||
|
||||
void history_collection_t::save() {
|
||||
// Save all histories
|
||||
auto hists = histories.acquire();
|
||||
for (auto &p : *hists) {
|
||||
void history_save_all() {
|
||||
auto histories = s_histories.acquire();
|
||||
for (auto &p : *histories) {
|
||||
p.second->save();
|
||||
}
|
||||
}
|
||||
|
||||
void history_save_all() { histories.save(); }
|
||||
|
||||
/// Return the prefix for the files to be used for command and read history.
|
||||
wcstring history_session_id(const environment_t &vars) {
|
||||
wcstring result = DFLT_FISH_HISTORY_SESSION_ID;
|
||||
|
|
Loading…
Reference in a new issue