From 3364850cc7cf73fc67af1ea6cd9a65a32e336623 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 29 Dec 2017 03:23:10 +0100 Subject: Use an std::set instead of an std::list to store the the journal file paths --- src/session.cc | 4 ++-- src/session.h | 4 ++-- 2 files changed, 4 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..82d9981f 100644 --- a/src/session.h +++ b/src/session.h @@ -143,14 +143,14 @@ public: OPTION__ (session_t, file_, // -f - std::list data_files; + std::set 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) { -- cgit v1.2.3 From 9409f25d0de638097a806f1f75b75473be192b82 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 29 Dec 2017 16:44:24 +0100 Subject: don't add paths to files, if there is already a path that points to the same file --- src/session.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/session.h b/src/session.h index 82d9981f..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,7 +153,7 @@ public: OPTION__ (session_t, file_, // -f - std::set data_files; + std::set data_files; CTOR(session_t, file_) {} DO_(str) { if (parent->flush_on_next_data_file) { -- cgit v1.2.3