There's a comment "Disable slow crap that doesn't matter for getting templates/files..." before a hack that appears to disable the 'ref' and 'references' tag hooks. Does this mean that templates used within a <nowiki><ref><nowiki> won't get recorded?
They don't get recorded with or without the hack in that case.
We sorted this out on IRC -- I meant "<ref>" referring to ref contents generally, ended up with a stray tag there. :)
With the hack behavior, it'll basically render the contents of the ref tags as simply inline wikitext that happens to be surrounded with some other text bits. This should expand everything needed well enough for these purposes, and apparently is much faster on some pages.
Will need to investigate those performance characteristics, but it looks fine here for now. Yay!
Tagged fixme until parser hacks reverted.