diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-17 04:57:38 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-17 04:57:38 -0400 |
commit | 325cf53ea74f7a7fe51fc30103594a3a92989f37 (patch) | |
tree | 4fe4cd9a0a943a6bd7c39c9487bdd0b592c954cd /amount.cc | |
parent | 9e235d04a1aa9d38fa6f1503902873d2f7ad8419 (diff) | |
download | fork-ledger-325cf53ea74f7a7fe51fc30103594a3a92989f37.tar.gz fork-ledger-325cf53ea74f7a7fe51fc30103594a3a92989f37.tar.bz2 fork-ledger-325cf53ea74f7a7fe51fc30103594a3a92989f37.zip |
several significant speed improvements (removed excessive copying of strings)
Diffstat (limited to 'amount.cc')
-rw-r--r-- | amount.cc | 38 |
1 files changed, 12 insertions, 26 deletions
@@ -1,6 +1,5 @@ -#include "amount.h" - -#include <list> +#include "ledger.h" +#include "util.h" #include "gmp.h" @@ -585,43 +584,30 @@ static inline char peek_next_nonws(std::istream& in) void parse_quantity(std::istream& in, std::string& value) { + static char buf[256]; char c = peek_next_nonws(in); - while (std::isdigit(c) || c == '-' || c == '.' || c == ',') { - in.get(c); - if (in.eof()) - break; - value += c; - c = in.peek(); - } + READ_INTO(in, buf, 256, c, + std::isdigit(c) || c == '-' || c == '.' || c == ','); + value = buf; } void parse_commodity(std::istream& in, std::string& symbol) { + static char buf[256]; + char c = peek_next_nonws(in); if (c == '"') { in.get(c); - c = in.peek(); - while (! in.eof() && c != '"') { - in.get(c); - if (c == '\\') - in.get(c); - symbol += c; - c = in.peek(); - } - + READ_INTO(in, buf, 256, c, c != '"'); if (c == '"') in.get(c); else assert(0); } else { - while (! std::isspace(c) && ! std::isdigit(c) && c != '-' && c != '.') { - in.get(c); - if (in.eof()) - break; - symbol += c; - c = in.peek(); - } + READ_INTO(in, buf, 256, c, ! std::isspace(c) && ! std::isdigit(c) && + c != '-' && c != '.'); } + symbol = buf; } void amount_t::parse(std::istream& in) |