This is the "main" function. It is called at the end of the script file
It does several things, and I will fill in the details as I figure it out over the next few hours.
1. It checks to see if we want to read in the config file, and if so, we do read it in.
2. It runs InitLinkPatterns, which does two important things... (a) Initialize the complicated regular expressions used to find links in the text and (b) set up the field separators that we use to read in the .db files.
3. Then it runs the code to handle the user's request:
But actually, the optimisation could be improved further. The biggest wasted compiler effort in the current model occurs when you do an "other" request that does not use the "browse" code at all.
For example, setting up for edit should be the fastest thing in the system - check if user is allowed to edit, send out a pretty standard form (only customisations are version-related stuff and warnings if there is conflict), and the text is provided in wiki format so none of that HTML conversion code is ever run.
Another example is indexing the site - as far as I can see there is no need for (most of) the browse code to run that.
The delay occurs because the current DeferredCompile strategy is to attempt to run each possibility in turn.
A faster strategy would be essentially to move the switch for DoOtherRequest and DoBrowseRequest into DoWikiRequest, and only compile further code after we know what we've got.
Very approximately it would look like this
if (DoCache) { return } &GetParam if (IsEdit) { compile edit set-up code Do Edit } elsif (IsBrowse) { compile browse code DoBrowseRequest } elsif (xxx) { compile xxx code DoXXXRequest } else { die "unknown request" }where xxx could be a single option or as many options bundled together as you like.
The further detail is that within the DoEdit code, at the point it becomes apparent that the browse code will be needed, it will have to be compiled (at present you safely rely on the fact that it has always been compiled before you get there).
Three further points
None of the above is a request for further work - just some ideas on how to take it forward if you or anyone else happen to feel like working on this.
--RiVer
PS - a third strategy is outlined on the WikiPatches/CiwiNi page