diff options
author | randomdan <randomdan@localhost> | 2010-07-13 23:54:37 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2010-07-13 23:54:37 +0000 |
commit | 6e19578c1389e642f5a23e8dae15a3c85335d4b4 (patch) | |
tree | 9abfafd8c156fccd366f65c14523923f7f45353b | |
parent | Reuse select commands for sql view and iterate (diff) | |
download | project2-6e19578c1389e642f5a23e8dae15a3c85335d4b4.tar.bz2 project2-6e19578c1389e642f5a23e8dae15a3c85335d4b4.tar.xz project2-6e19578c1389e642f5a23e8dae15a3c85335d4b4.zip |
Don't reference rows before they're put on the stack
-rw-r--r-- | project2/variables.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/project2/variables.cpp b/project2/variables.cpp index cafb336..9aa1a5b 100644 --- a/project2/variables.cpp +++ b/project2/variables.cpp @@ -63,23 +63,25 @@ class VariableUri : public VariableImplDyn { class VariableParent : public VariableImplDyn, public RowUser { public: - VariableParent(const Glib::ustring & src, RowUser * dep) : - VariableImplDyn(Glib::ustring(std::find_if(src.begin(), src.end(), isalpha), src.end())) + VariableParent(const Glib::ustring & src, const RowUser * d) : + VariableImplDyn(Glib::ustring(std::find_if(src.begin(), src.end(), isalpha), src.end())), + row(NULL), + depth(src.length() - source.length()), + dep(d) { - PerRowValues::RowValuesStack::const_iterator r = PerRowValues::Stack().end(); - size_t p = src.length() - source.length(); - while (--p) { - r--; - } - row = *r; - row->use(this); - if (dep) { - row->use(dep); - } } const Glib::ustring & value() const { if (!cacheValid) { + if (!row) { + PerRowValues::RowValuesStack::const_reverse_iterator r = PerRowValues::Stack().rbegin(); + for (size_t p = depth; --p; r++) ; + row = *r; + row->use(this); + if (dep) { + row->use(dep); + } + } cache = row->getCurrentValue(source); cacheValid = true; } @@ -90,7 +92,9 @@ class VariableParent : public VariableImplDyn, public RowUser { cacheValid = false; } protected: - const PerRowValues * row; + mutable const PerRowValues * row; + const size_t depth; + const RowUser * dep; }; class VariableParse : public VariableImplDyn, public RowUser { |