0

I'm trying to optimise a html parser for a Roku application I'm helping to develop. The parser currently takes too long to parse the data (8 seconds) and it does this by recursivly traversing the children of each tag encountered within a for each loop.

parser (nodes):
 for each node in nodes
   if node.isTag
     parser(node.nodes)
  else if node.isBlock
     text.push(node) 

something akin to that, although much more convoluted! I'm assuming it's slow because it's recursive and there is no tail recursion optimisation on the platform etc

I'm not too sure how to implement a stack to remove the recursiveness from this - I've tried using GoTo but that didn't seem to work :/

Can anyone provide some insight, and or whether you think the problem might be caused by the recursion?

CWright
  • 2,068
  • 2
  • 16
  • 20

1 Answers1

0

What are you trying to achieve? Some boxes are slow, there is only a certain amount of optimisation you can apply. If you need to parse the whole document, it usually takes what it takes. We had similar problem, app froze for a few seconds, looking like it's crashed but we got around it by displaying asynchronous spinning icon.

Tom Ash
  • 16