How to improve Web Source scripts performance?



As I've been coding a tag source script for Google Play Music I've found that the lack of arithmetic functions in the framework entails having to resort to convoluted loops to do the dirty work and grab some tricky data that is not easily readable in the HTML code. This also results in slow scripts when parsing albums with lots of tracks.

Are there any strategies to get scripts that run faster?

  • Which way is preferred: FindLine-SayRegexp or combinations of FindLine-FindInLine-SayUntil/SayNextNumber?

  • Best code structure to emulate using counter variables?

  • Would it be better to use RegexpReplace at the beginning of the script to get rid of big chunks of text that don't contain relevant information?

I would appreciate any ideas on this topic.