summaryrefslogtreecommitdiff
path: root/project2/variables.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/variables.cpp')
-rw-r--r--project2/variables.cpp30
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 {