summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-09-06 05:38:32 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-09-06 05:38:32 -0400
commitfcaaa372019b525980e40b148a1d542ab3acced9 (patch)
tree568e2715bdc27817c39d25062bd1b22b5812f244
parent305c6159afe727c6e6f2f49c37789922df1a5a98 (diff)
downloadfork-ledger-fcaaa372019b525980e40b148a1d542ab3acced9.tar.gz
fork-ledger-fcaaa372019b525980e40b148a1d542ab3acced9.tar.bz2
fork-ledger-fcaaa372019b525980e40b148a1d542ab3acced9.zip
switch from using deque back to list; affects speed by up to 30%!
-rwxr-xr-xacprep3
-rw-r--r--config.cc8
-rw-r--r--ledger.h8
-rw-r--r--main.cc2
-rw-r--r--option.cc16
-rw-r--r--option.h4
-rw-r--r--walk.cc4
-rw-r--r--walk.h31
8 files changed, 45 insertions, 31 deletions
diff --git a/acprep b/acprep
index a1a5ea16..aa3d01c0 100755
--- a/acprep
+++ b/acprep
@@ -22,8 +22,7 @@ if [ "$1" = "--debug" ]; then
CXXFLAGS="-g" --enable-debug --disable-shared
elif [ "$1" = "--opt" ]; then
./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" \
- CXXFLAGS="-fomit-frame-pointer -fastf -mcpu=7450 -fPIC" \
- --enable-standalone --disable-shared
+ CXXFLAGS="-fomit-frame-pointer -fastf -mcpu=7450" --disable-shared
elif [ "$1" = "--perf" ]; then
./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" CXXFLAGS="-g -pg"
fi
diff --git a/config.cc b/config.cc
index f090a09e..0dff2a47 100644
--- a/config.cc
+++ b/config.cc
@@ -47,8 +47,8 @@ config_t::config_t()
static void
regexps_to_predicate(config_t& config,
- std::deque<std::string>::const_iterator begin,
- std::deque<std::string>::const_iterator end,
+ std::list<std::string>::const_iterator begin,
+ std::list<std::string>::const_iterator end,
const bool account_regexp = false,
const bool add_account_short_masks = false)
{
@@ -57,7 +57,7 @@ regexps_to_predicate(config_t& config,
// Treat the remaining command-line arguments as regular
// expressions, used for refining report results.
- for (std::deque<std::string>::const_iterator i = begin;
+ for (std::list<std::string>::const_iterator i = begin;
i != end;
i++)
if ((*i)[0] == '-') {
@@ -137,7 +137,7 @@ void config_t::process_options(const std::string& command,
// Treat the remaining command-line arguments as regular
// expressions, used for refining report results.
- std::deque<std::string>::iterator i = arg;
+ std::list<std::string>::iterator i = arg;
for (; i != args_end; i++)
if (*i == "--")
break;
diff --git a/ledger.h b/ledger.h
index e52a1e83..1d64e4e1 100644
--- a/ledger.h
+++ b/ledger.h
@@ -11,7 +11,7 @@
//
#include <map>
-#include <deque>
+#include <list>
#include <string>
#include <ctime>
#include <iostream>
@@ -121,7 +121,7 @@ value_t& add_transaction_to(const transaction_t& xact, value_t& value)
return value;
}
-typedef std::deque<transaction_t *> transactions_list;
+typedef std::list<transaction_t *> transactions_list;
class entry_t
{
@@ -214,8 +214,8 @@ inline std::ostream& operator<<(std::ostream& out, const account_t& acct) {
}
-typedef std::deque<entry_t *> entries_list;
-typedef std::deque<std::string> strings_list;
+typedef std::list<entry_t *> entries_list;
+typedef std::list<std::string> strings_list;
class journal_t
{
diff --git a/main.cc b/main.cc
index 6ae0bb21..42501544 100644
--- a/main.cc
+++ b/main.cc
@@ -230,7 +230,7 @@ int parse_and_report(int argc, char * argv[], char * envp[])
TIMER_START(process_opts);
- std::deque<std::string> args;
+ std::list<std::string> args;
process_arguments(argc - 1, argv + 1, false, args);
if (args.empty()) {
diff --git a/option.cc b/option.cc
index 7e0a74f3..f4053e4e 100644
--- a/option.cc
+++ b/option.cc
@@ -6,7 +6,7 @@
#include "util.h"
-static std::deque<option_t> options;
+static std::list<option_t> options;
void register_option(const std::string& label,
const std::string& opt_chars,
@@ -50,7 +50,7 @@ static inline void process_option(const option_t& opt,
bool process_option(const std::string& opt, const char * arg)
{
- for (std::deque<option_t>::iterator i = options.begin();
+ for (std::list<option_t>::iterator i = options.begin();
i != options.end();
i++)
if ((*i).long_opt == opt) {
@@ -66,7 +66,7 @@ bool process_option(const std::string& opt, const char * arg)
}
void process_arguments(int argc, char ** argv, const bool anywhere,
- std::deque<std::string>& args)
+ std::list<std::string>& args)
{
int index = 0;
for (char ** i = argv; index < argc; i++, index++) {
@@ -87,7 +87,7 @@ void process_arguments(int argc, char ** argv, const bool anywhere,
if ((*i)[2] == '\0')
break;
- for (std::deque<option_t>::iterator j = options.begin();
+ for (std::list<option_t>::iterator j = options.begin();
j != options.end();
j++)
if ((*j).wants_arg) {
@@ -111,7 +111,7 @@ void process_arguments(int argc, char ** argv, const bool anywhere,
std::cerr << "Error: illegal option " << *i << std::endl;
std::exit(1);
} else {
- for (std::deque<option_t>::iterator j = options.begin();
+ for (std::list<option_t>::iterator j = options.begin();
j != options.end();
j++)
if ((*i)[1] == (*j).short_opt) {
@@ -180,7 +180,7 @@ struct func_option_wrapper : public option_handler
}
};
-static std::deque<func_option_wrapper> wrappers;
+static std::list<func_option_wrapper> wrappers;
void py_register_option(const std::string& long_opt,
const std::string& short_opt, object func)
@@ -200,11 +200,11 @@ list py_process_arguments(list args, bool anywhere = false)
for (int i = 0; i < l; i++)
strs.push_back(extract<char *>(args[i]));
- std::deque<std::string> newargs;
+ std::list<std::string> newargs;
process_arguments(strs.size(), &strs.front(), anywhere, newargs);
list py_newargs;
- for (std::deque<std::string>::iterator i = newargs.begin();
+ for (std::list<std::string>::iterator i = newargs.begin();
i != newargs.end();
i++)
py_newargs.append(*i);
diff --git a/option.h b/option.h
index 44ca5b3b..fe073274 100644
--- a/option.h
+++ b/option.h
@@ -1,7 +1,7 @@
#ifndef _OPTION_H
#define _OPTION_H
-#include <deque>
+#include <list>
#include <string>
struct option_handler {
@@ -23,7 +23,7 @@ void register_option(const std::string& label,
const std::string& opt_chars, option_handler& option);
bool process_option(const std::string& opt, const char * arg = NULL);
void process_arguments(int argc, char ** argv, const bool anywhere,
- std::deque<std::string>& args);
+ std::list<std::string>& args);
void process_environment(char ** envp, const std::string& tag);
#endif // _OPTION_H
diff --git a/walk.cc b/walk.cc
index a8111597..61c3fa30 100644
--- a/walk.cc
+++ b/walk.cc
@@ -8,7 +8,7 @@ void sort_transactions::flush()
std::stable_sort(transactions.begin(), transactions.end(),
compare_items<transaction_t>(sort_order));
- for (std::deque<transaction_t *>::iterator i = transactions.begin();
+ for (transactions_deque::iterator i = transactions.begin();
i != transactions.end();
i++)
(*handler)(**i);
@@ -290,7 +290,7 @@ void interval_transactions::operator()(transaction_t& xact)
void dow_transactions::flush()
{
for (int i = 0; i < 7; i++) {
- for (std::deque<transaction_t *>::iterator d = days_of_the_week[i].begin();
+ for (transactions_list::iterator d = days_of_the_week[i].begin();
d != days_of_the_week[i].end();
d++)
subtotal_transactions::operator()(**d);
diff --git a/walk.h b/walk.h
index 00296082..d9946ed9 100644
--- a/walk.h
+++ b/walk.h
@@ -67,6 +67,9 @@ class compare_items {
// Transaction handlers
//
+typedef std::deque<transaction_t *> transactions_deque;
+typedef std::deque<entry_t *> entries_deque;
+
inline void walk_transactions(transactions_list::iterator begin,
transactions_list::iterator end,
item_handler<transaction_t>& handler) {
@@ -74,7 +77,19 @@ inline void walk_transactions(transactions_list::iterator begin,
handler(**i);
}
-inline void walk_transactions(transactions_list& deque,
+inline void walk_transactions(transactions_list& list,
+ item_handler<transaction_t>& handler) {
+ walk_transactions(list.begin(), list.end(), handler);
+}
+
+inline void walk_transactions(transactions_deque::iterator begin,
+ transactions_deque::iterator end,
+ item_handler<transaction_t>& handler) {
+ for (transactions_deque::iterator i = begin; i != end; i++)
+ handler(**i);
+}
+
+inline void walk_transactions(transactions_deque& deque,
item_handler<transaction_t>& handler) {
walk_transactions(deque.begin(), deque.end(), handler);
}
@@ -179,8 +194,8 @@ class set_account_value : public item_handler<transaction_t>
class sort_transactions : public item_handler<transaction_t>
{
- std::deque<transaction_t *> transactions;
- const value_expr_t * sort_order;
+ transactions_deque transactions;
+ const value_expr_t * sort_order;
public:
sort_transactions(item_handler<transaction_t> * handler,
@@ -387,7 +402,7 @@ class interval_transactions : public subtotal_transactions
class dow_transactions : public subtotal_transactions
{
- std::deque<transaction_t *> days_of_the_week[7];
+ transactions_list days_of_the_week[7];
public:
dow_transactions(item_handler<transaction_t> * handler)
@@ -459,11 +474,11 @@ inline void sum_accounts(account_t& account) {
ACCT_DATA_(account)->count += ACCT_DATA_(account)->subcount;
}
-typedef std::deque<account_t *> accounts_list;
+typedef std::deque<account_t *> accounts_deque;
inline void sort_accounts(account_t& account,
const value_expr_t * sort_order,
- accounts_list& accounts) {
+ accounts_deque& accounts) {
for (accounts_map::iterator i = account.accounts.begin();
i != account.accounts.end();
i++)
@@ -479,9 +494,9 @@ inline void walk_accounts(account_t& account,
handler(account);
if (sort_order) {
- accounts_list accounts;
+ accounts_deque accounts;
sort_accounts(account, sort_order, accounts);
- for (accounts_list::const_iterator i = accounts.begin();
+ for (accounts_deque::const_iterator i = accounts.begin();
i != accounts.end();
i++)
walk_accounts(**i, handler, sort_order);