Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 9e1686d9 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

- DHParser/syntaxtree.py Node.content optimized so as to minimize string copy operations

parent af07a4db
......@@ -354,6 +354,18 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
self.children = NoChildren
self._result = result # cast(StrictResultType, result)
def _content(self) -> List[str]:
"""
Returns string content as list of string fragments
that are gathered from all child nodes in order.
"""
if self.children:
fragments = []
for child in self.children:
fragments.extend(child._content())
return fragments
self._result = str(self._result)
return [self._result]
@property
def content(self) -> str:
......@@ -362,7 +374,11 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
string content of the child-nodes is recursively read and then
concatenated.
"""
return "".join(child.content for child in self.children) if self.children else str(self._result)
return ''.join(self._content())
## unoptimized
# return "".join(child.content for child in self.children) if self.children else str(
# self._result)
## obsolete
# if self._content is None:
# if self.children:
# self._content = "".join(child.content for child in self.children)
......
......@@ -81,6 +81,17 @@ class TestNode:
self.recurring_nodes_sexpr = '(a (b x) (c (d e) (b y)))'
self.recurr_tree = parse_sxpr(self.recurring_nodes_sexpr)
def test_content_property(self):
tree = RootNode(parse_sxpr('(a (b c) (d e))'))
content = tree.content
b = tree.pick('b')
d = tree.pick('d')
b.result = "recently "
d.result = "changed"
assert content != tree.content
assert content == 'ce'
assert tree.content == 'recently changed'
def test_deepcopy(self):
tree = RootNode(parse_sxpr('(a (b c) (d (e f) (h i)))'))
tree.with_pos(0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment