Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
badw-it
DHParser
Commits
e2e999b1
Commit
e2e999b1
authored
Aug 22, 2017
by
Eckhart Arnold
Browse files
syntaxtree.py Node().children field instead of property for speed optimization
parent
c90f13a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
DHParser/syntaxtree.py
View file @
e2e999b1
...
...
@@ -195,8 +195,8 @@ class Node:
# self._children = () # type: ChildrenType
self
.
_errors
=
[]
# type: List[str]
self
.
result
=
result
self
.
_len
=
len
(
result
)
if
not
self
.
_
children
else
\
sum
(
child
.
_len
for
child
in
self
.
_
children
)
# type: int
self
.
_len
=
len
(
result
)
if
not
self
.
children
else
\
sum
(
child
.
_len
for
child
in
self
.
children
)
# type: int
# self.pos: int = 0 # continuous updating of pos values wastes a lot of time
self
.
_pos
=
-
1
# type: int
self
.
parser
=
parser
or
ZOMBIE_PARSER
...
...
@@ -248,15 +248,14 @@ class Node:
# or isinstance(result, Node)
# or isinstance(result, str)), str(result)
self
.
_result
=
(
result
,)
if
isinstance
(
result
,
Node
)
else
result
or
''
# type: StrictResultType
self
.
_
children
=
cast
(
ChildrenType
,
self
.
_result
)
\
self
.
children
=
cast
(
ChildrenType
,
self
.
_result
)
\
if
isinstance
(
self
.
_result
,
tuple
)
else
cast
(
ChildrenType
,
())
# type: ChildrenType
self
.
error_flag
=
any
(
r
.
error_flag
for
r
in
self
.
_
children
)
\
if
self
.
_
children
else
False
# type: bool
self
.
error_flag
=
any
(
r
.
error_flag
for
r
in
self
.
children
)
\
if
self
.
children
else
False
# type: bool
@
property
def
children
(
self
)
->
ChildrenType
:
return
self
.
_children
# @property
# def children(self) -> ChildrenType:
# return self._children
@
property
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment