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 | bcfc98e111aeefd6406523f07df762163f0e1524 (patch) | |
tree | 9abfafd8c156fccd366f65c14523923f7f45353b | |
parent | Reuse select commands for sql view and iterate (diff) | |
download | project2-bcfc98e111aeefd6406523f07df762163f0e1524.tar.bz2 project2-bcfc98e111aeefd6406523f07df762163f0e1524.tar.xz project2-bcfc98e111aeefd6406523f07df762163f0e1524.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 { |