Skip to content

Commit

Permalink
Remove useless name mangling for __cacheParent
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienRietteMTO committed Oct 14, 2024
1 parent b989695 commit 000ca1d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/pyft/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ def __init__(self, xml, scopePath='/', parentScope=None,
self._path = scopePath
self._parentScope = parentScope
self.tree = Tree() if tree is None else tree
self.__cacheParent = {}
self._cacheParent = {}

if enableCache and parentScope is None:
# parent cache associated to the main scope
for node in self.iter():
for subNode in node:
self.__cacheParent[id(subNode)] = node
self._cacheParent[id(subNode)] = node

def __copy__(self):
cls = self.__class__
Expand Down Expand Up @@ -287,21 +287,21 @@ def getParent(self, item, level=1):
def check(node):
# We check if the registered parent is still the right one
# node must be in its parent, and the parent chain must go to the root node
return node in self.mainScope.__cacheParent.get(id(node), []) and \
(self.mainScope.__cacheParent[id(node)] == self.mainScope._xml or
check(self.mainScope.__cacheParent[id(node)]))
return node in self.mainScope._cacheParent.get(id(node), []) and \
(self.mainScope._cacheParent[id(node)] == self.mainScope._xml or
check(self.mainScope._cacheParent[id(node)]))

assert level >= 1
parent = None
if check(item):
parent = self.mainScope.__cacheParent[id(item)]
parent = self.mainScope._cacheParent[id(item)]
else:
for node in self.mainScope.iter():
if item in list(node):
parent = node
if self.mainScope.__cacheParent:
# __cacheParent not empty means that we want to use the caching system
self.mainScope.__cacheParent[id(item)] = node
if self.mainScope._cacheParent:
# _cacheParent not empty means that we want to use the caching system
self.mainScope._cacheParent[id(item)] = node
break
return parent if level == 1 else self.getParent(parent, level - 1)

Expand Down

0 comments on commit 000ca1d

Please sign in to comment.