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,14 +161,16 @@ class VariableStorage(MutableMapping):
|
|||
restored. The cache will be reset.
|
||||
"""
|
||||
restore = self._script_stack.pop()
|
||||
if not restore:
|
||||
return
|
||||
unchanged = 0
|
||||
for vn, vv in restore.items():
|
||||
existed, value = vv
|
||||
if existed:
|
||||
self._script_vars[vn] = value
|
||||
elif vn in self._script_vars:
|
||||
del self._script_vars[vn]
|
||||
else:
|
||||
unchanged += 1
|
||||
if unchanged != len(restore):
|
||||
self._cache = self._host_vars.copy()
|
||||
self._cache.update(self._script_vars)
|
||||
|
||||
|
|
Loading…
Reference in a new issue