Don't reset the cache on pop if no deletion occurs
When the stack is being pop'd, it is not necessary to reset it if no variable is either reset to its previous value or deleted.
This commit is contained in:
parent
91a90def13
commit
f42df48a1b
1 changed files with 6 additions and 4 deletions
|
@ -161,16 +161,18 @@ class VariableStorage(MutableMapping):
|
||||||
restored. The cache will be reset.
|
restored. The cache will be reset.
|
||||||
"""
|
"""
|
||||||
restore = self._script_stack.pop()
|
restore = self._script_stack.pop()
|
||||||
if not restore:
|
unchanged = 0
|
||||||
return
|
|
||||||
for vn, vv in restore.items():
|
for vn, vv in restore.items():
|
||||||
existed, value = vv
|
existed, value = vv
|
||||||
if existed:
|
if existed:
|
||||||
self._script_vars[vn] = value
|
self._script_vars[vn] = value
|
||||||
elif vn in self._script_vars:
|
elif vn in self._script_vars:
|
||||||
del self._script_vars[vn]
|
del self._script_vars[vn]
|
||||||
self._cache = self._host_vars.copy()
|
else:
|
||||||
self._cache.update(self._script_vars)
|
unchanged += 1
|
||||||
|
if unchanged != len(restore):
|
||||||
|
self._cache = self._host_vars.copy()
|
||||||
|
self._cache.update(self._script_vars)
|
||||||
|
|
||||||
def _set_host_var(self, name, value):
|
def _set_host_var(self, name, value):
|
||||||
"""Set a host variable.
|
"""Set a host variable.
|
||||||
|
|
Loading…
Reference in a new issue