Module talk:Delink: Difference between revisions

Content deleted Content added
Zebulon84 (talk | contribs)
No edit summary
Line 18:
 
:::You can see the regressions in the test cases ([[Module talk:Delink/testcases]]). Not all of those tests pass with the main module, though, so beware. As for when to use the string library instead of the mw.ustring library, I got [https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:Lua&diff=594064888&oldid=593972746 this very helpful reply] by Anomie in February which made things much clearer for me. Basically, if we are only looking for ASCII text, then we should be fine to use the Lua string library functions. Also, another thing which can make things faster is to anchor your patterns where possible. For example, inside the delinkWikilink function you were doing a gsub of the pattern '%[%[.-%]%]'. In this case we know that the end two brackets are at the end of the string, but Lua doesn't know this, so it checks every possible ___location of both the starting brackets and the ending brackets to see if there is a match. If we anchor the string like '%[%[.-%]%]$', then Lua only has to check every possible ___location of the starting brackets, which is a lot quicker. I'm also wondering if we could make things more efficient by splitting the wikilink up into a table of different parts before processing each part, but that plan is only in the early stages yet. I'll report back here when I have some results. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 12:11, 18 April 2014 (UTC)
::::Thanks for all theses details.
::::I've applied your "use string library functions" modifications. I prefer the single quotes too so I've taken this part too.
::::I've analyzed the Unit tests to improve the results. I eventually understood how wiki decodes links, and have all this correct :
::::* {{Plain link|url=//fr.wikipedia.org/w/index.php?title=Module%3ADelink&diff=103191852&oldid=103185972 the evolution I did}}
::::* [[fr:Discussion module:Delink/Test|the unit tests with that code]]
::::Just one question about your sanitizing : local function are quicker than function in a table. So why do you declare all the functions as part of the returned <code>p</code> table ? Their name starting with underscore show that you don't expect them to be used outside this module anyway.
::::[[User:Zebulon84|Zebulon84]] ([[User talk:Zebulon84|talk]]) 16:51, 25 April 2014 (UTC)