Fix to inlinefuncs stack cache to make it properly use the cached value.
This commit is contained in:
parent
203d0a09a0
commit
dcde526f6d
1 changed files with 61 additions and 60 deletions
|
|
@ -266,14 +266,14 @@ def parse_inlinefunc(string, strip=False, **kwargs):
|
|||
if string in _PARSING_CACHE:
|
||||
# stack is already cached
|
||||
stack = _PARSING_CACHE[string]
|
||||
else:
|
||||
# not a cached string.
|
||||
if not _RE_STARTTOKEN.search(string):
|
||||
elif not _RE_STARTTOKEN.search(string):
|
||||
# if there are no unescaped start tokens at all, return immediately.
|
||||
return string
|
||||
|
||||
# build a new cache entry
|
||||
else:
|
||||
# no cached stack; build a new stack and continue
|
||||
stack = ParseStack()
|
||||
|
||||
# process string on stack
|
||||
ncallable = 0
|
||||
for match in _RE_TOKEN.finditer(string):
|
||||
gdict = match.groupdict()
|
||||
|
|
@ -329,7 +329,7 @@ def parse_inlinefunc(string, strip=False, **kwargs):
|
|||
# if stack is larger than limit, throw away parsing
|
||||
return string + gdict["stackfull"](*args, **kwargs)
|
||||
else:
|
||||
# cache the result
|
||||
# cache the stack
|
||||
_PARSING_CACHE[string] = stack
|
||||
|
||||
# run the stack recursively
|
||||
|
|
@ -356,6 +356,7 @@ def parse_inlinefunc(string, strip=False, **kwargs):
|
|||
# execute the stack from the cache
|
||||
return "".join(_run_stack(item) for item in _PARSING_CACHE[string])
|
||||
|
||||
#
|
||||
# Nick templating
|
||||
#
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue