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:
|
if string in _PARSING_CACHE:
|
||||||
# stack is already cached
|
# stack is already cached
|
||||||
stack = _PARSING_CACHE[string]
|
stack = _PARSING_CACHE[string]
|
||||||
else:
|
elif not _RE_STARTTOKEN.search(string):
|
||||||
# not a cached string.
|
|
||||||
if not _RE_STARTTOKEN.search(string):
|
|
||||||
# if there are no unescaped start tokens at all, return immediately.
|
# if there are no unescaped start tokens at all, return immediately.
|
||||||
return string
|
return string
|
||||||
|
else:
|
||||||
# build a new cache entry
|
# no cached stack; build a new stack and continue
|
||||||
stack = ParseStack()
|
stack = ParseStack()
|
||||||
|
|
||||||
|
# process string on stack
|
||||||
ncallable = 0
|
ncallable = 0
|
||||||
for match in _RE_TOKEN.finditer(string):
|
for match in _RE_TOKEN.finditer(string):
|
||||||
gdict = match.groupdict()
|
gdict = match.groupdict()
|
||||||
|
|
@ -329,7 +329,7 @@ def parse_inlinefunc(string, strip=False, **kwargs):
|
||||||
# if stack is larger than limit, throw away parsing
|
# if stack is larger than limit, throw away parsing
|
||||||
return string + gdict["stackfull"](*args, **kwargs)
|
return string + gdict["stackfull"](*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
# cache the result
|
# cache the stack
|
||||||
_PARSING_CACHE[string] = stack
|
_PARSING_CACHE[string] = stack
|
||||||
|
|
||||||
# run the stack recursively
|
# run the stack recursively
|
||||||
|
|
@ -356,6 +356,7 @@ def parse_inlinefunc(string, strip=False, **kwargs):
|
||||||
# execute the stack from the cache
|
# execute the stack from the cache
|
||||||
return "".join(_run_stack(item) for item in _PARSING_CACHE[string])
|
return "".join(_run_stack(item) for item in _PARSING_CACHE[string])
|
||||||
|
|
||||||
|
#
|
||||||
# Nick templating
|
# Nick templating
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue