[ALOY-27] Improve HTML parsing performance
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-07-19T11:52:06.000+0000 |
Affected Version/s | 2012 Sprint 14 |
Fix Version/s | 2012 Sprint 14 |
Components | XML |
Labels | n/a |
Reporter | Tony Lukasavage |
Assignee | Tony Lukasavage |
Created | 2012-05-11T08:24:31.000+0000 |
Updated | 2014-06-22T13:21:20.000+0000 |
Description
Right now, everytime the generated HTML parser
parser/html.js
is called in parser/parser.js
, the entire document is parsed. We should not be making multiple calls to html.parser()
, we should either be processing all relevant HTML elements in a single call to html.parser()
, or make use of the different startRule
values available in parser/html.js
.
This may not be an issue now, but as apps grow more complex, inefficient parsing could adversely effect build time.
Already built into the parsing is passing in an already created object tree, so no need to parse every time . Needs testing though.
Right, but wouldn't you need to traverse the object tree to know what to pass in? Since the object tree corresponds to our custom HTML grammar, there's no easy/efficient way to use selectors to traverse it.
You can also pass in parts so it limits what is scanned. As to selectors something you do need to scan the whole tree to return a collection but in the case of id once the object is created it's a hash map lookup so no dom scanning.
details here: [https://github.com/appcelerator/ZipTi/commit/cde130b26b91a1eb5f9d08bfc1ac0e9df7d4a9a6](https://github.com/appcelerator/ZipTi/commit/cde130b26b91a1eb5f9d08bfc1ac0e9df7d4a9a6)