Board Thread:Lua Help/@comment-4405550-20160107031030/@comment-4405550-20160108130620

Cqm wrote: ...it's not really necessary on the page you've linked to. The time used by Lua on that page is ~0.2 seconds out of 10. You're a long, long way away from needing to optimise tiny details. It's not until you're getting issues like w:c:rs:User:Cqm/Scrapbook 7 that you need to get creative ;) Haha well I didn't link you to this page. It's from my legacy script, but you get the idea.

And I'm ripping data directly from the game's code (reddit post) and I have 1700+ item pages alone to upload. And the the equipment pages dont even show all the data available simply because I haven't written it yet. And every time the game is updated, I will have to do a massive bot edit.

I just don't want Wikia employees outside my house with knives and pitchforks because I set their servers on fire :/

Dessamator wrote: While it is possible to add these things as a gadget, you'd have to know what those good practices are. You'd also have to write code for the Lua Lint wikia or whatever WMF uses for scribunto. I'm not exactly sure which library lua uses for their Lua lint, but it may be possible to submit a pull request for it and add these optimizations. I don't even think we need to go that far. Since I'm no longer proposing the program make the changes itself, but just give helpful tips, the idea gets much simpler. If we just strip comments, break the script apart by block/sub-block (functions, loops, etc...), and preserve some kind of context/closure info (orig line number, parent blocks), the program would just have to run a few regex patterns to identify any issues. From there, it's just a matter of recognizing the overall context in which the issue was identified, and determining the validity.

A simple RegExp like this would identify concats that can be joined (wont work in JS with the named backref, but you get the idea): (? (? [\'\"])(? (?:\\\k |(?:(?!\k ).))*)\k (? [\s\r\n]+\.\.[\s\r\n]+)\k \g \k ) but this would be acceptable in some places (like if a function were called on the left side of the string construction).

Sorry, my inner CS came out :(

But parsers are super simple to write when you aren't actually trying to evaluate the code.