-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xml ast improvements #376
Xml ast improvements #376
Conversation
- move all module functions into SGParser class. - Remove unnecessary SG transpile functions in favor of the base class. - Refactor SG class fields to getter functions and rely on underlying xml structure instead of member arrays.
I made a few small performance improvements to the SGParser which increased the parse-xml from I refactored the logic to find the XML node's bounding range to be computed on-demand instead of during every parse. |
We need to ensure also that we support "unknown" tags and attributes everywhere. |
default: | ||
const nodeContent = mapNodes(content); | ||
return new SGNode(name, attributes, nodeContent, range); | ||
mapElement({ children }: ElementCstNode): SGTag { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like seeing all these pure functions moved into the classe but well...
Closed in favor of #400 |
This is part of the large set of breaking changes PR series (including #329).
Depends on #375
Notable changes:
range
property) to all SceneGraph/XML nodes.transpile()
functions in favor of the function from the base class.SGComponent
scripts
,children
, andinterface
properties into getter functions which are driven by the underlying XML AST. This means as you modify the AST, those getter functions will automatically reflect the changes.SGInterface
propertiesfields
andfunctions
to getter functions which are driven by the underlying XML AST (same benefits as previous point).SGParser
module functions onto the SGParser class itself to match the OO patterns in the rest of the project.The additional location tracking does result in a performance slowdown for XML parsing. However, considering XML files are generally pretty small (compared to brs files) and also considering that xml parsing is still over 200% faster than brs parsing, the XML location tracking is well worth the performance hit. However, I will be running a node profiler to see if I can squeeze out any additional performance.