On 03/30/2011 09:22 AM, Magnus Manske wrote:
Plus, free C++ MediaWiki parser ;-)
Seriously, there should be a way to turn the entire package into a (huge) library; maybe transpile it and then replace the C++ code for index.php with a manually written library interface?
HipHop has a library generation feature. It even has an option to provide public interfaces with human-readable names.
Offline readers, scientific analysis tools, etc. could profit massively from an always-current, fast C++ library...
Speaking of "fast", I did a quick benchmark of the [[Barack Obama]] article with templates pre-expanded. It took 22 seconds in HipHop and 112 seconds in Zend, which is not bad, for a first attempt. I reckon it would do better if a few of the regular expressions were replaced with tight loops.
Also, browsing the generated source turns up silly things like:
if (equal(switch2, (NAMSTR(s_ss34c5c84c, "currentmonth")))) goto case_2_0; if (equal(switch2, (NAMSTR(s_ss55b88086, "currentmonth1")))) goto case_2_1; if (equal(switch2, (NAMSTR(s_ss0ccbf467, "currentmonthname")))) goto case_2_2; if (equal(switch2, (NAMSTR(s_ss513d5737, "currentmonthnamegen")))) goto case_2_3; if (equal(switch2, (NAMSTR(s_ss004d8db5, "currentmonthabbrev")))) goto case_2_4; if (equal(switch2, (NAMSTR(s_ssf9584d41, "currentday")))) goto case_2_5;
71 string comparisons in total, in quite a hot function. A hashtable would probably be better.
-- Tim Starling