diff options
author | John Wiegley <johnw@newartisans.com> | 2017-12-30 11:27:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-30 11:27:12 -0800 |
commit | dc4cb5e623dff270b9298f9e99f352090719435b (patch) | |
tree | 120735640c78bd7de1785bc9f09a2f368c5abc10 | |
parent | 77ae14230b0ce38cc2c7fee401d7b6aeb2610191 (diff) | |
parent | 9409f25d0de638097a806f1f75b75473be192b82 (diff) | |
download | fork-ledger-dc4cb5e623dff270b9298f9e99f352090719435b.tar.gz fork-ledger-dc4cb5e623dff270b9298f9e99f352090719435b.tar.bz2 fork-ledger-dc4cb5e623dff270b9298f9e99f352090719435b.zip |
Merge pull request #503 from ghost91-/next
Use an std::set instead of an std::list to store the the journal file paths
-rw-r--r-- | src/session.cc | 4 | ||||
-rw-r--r-- | src/session.h | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/session.cc b/src/session.cc index deba3afa..11d67cea 100644 --- a/src/session.cc +++ b/src/session.cc @@ -76,7 +76,7 @@ std::size_t session_t::read_data(const string& master_account) file = path(home_var) / ".ledger"; if (! file.empty() && exists(file)) - HANDLER(file_).data_files.push_back(file); + HANDLER(file_).data_files.insert(file); else throw_(parse_error, "No journal file was specified (please use -f)"); @@ -214,7 +214,7 @@ journal_t * session_t::read_journal_files() journal_t * session_t::read_journal(const path& pathname) { HANDLER(file_).data_files.clear(); - HANDLER(file_).data_files.push_back(pathname); + HANDLER(file_).data_files.insert(pathname); return read_journal_files(); } diff --git a/src/session.h b/src/session.h index bb9c5f7e..7e299959 100644 --- a/src/session.h +++ b/src/session.h @@ -52,6 +52,16 @@ namespace ledger { class xact_t; +struct ComparePaths +{ + bool operator()(const path& p1, const path& p2) const + { + return p1 < p2 && !boost::filesystem::equivalent(p1, p2); + } +}; + +#define COMMA , + class session_t : public symbol_scope_t { friend void set_session_context(session_t * session); @@ -143,14 +153,14 @@ public: OPTION__ (session_t, file_, // -f - std::list<path> data_files; + std::set<path COMMA ComparePaths> data_files; CTOR(session_t, file_) {} DO_(str) { if (parent->flush_on_next_data_file) { data_files.clear(); parent->flush_on_next_data_file = false; } - data_files.push_back(str); + data_files.insert(str); }); OPTION_(session_t, input_date_format_, DO_(str) { |