Jean-Marc Lasgouttes wrote: > > I tried to open a file under a gprof'd lyx to see where the slowness > came from. I was very surprised to find the following: > > 0.00 0.40 43/43 > InsetCitation::generateLabel(Buffer const&) const [21] > [20] 19.5 0.00 0.40 43 (anonymous > [namespace)::getNatbibLabel(Buffer const&, string const&, string const&, > [string const&, string const&, lyx::biblio::CiteEngine) [20] > 0.01 0.39 43/43 > Buffer::fillWithBibKeys(vector<pair<string, string >, > allocator<pair<string, string > > >&) const [23] > > [Actually, the output was far worse than that...] > > What it says is that InsetCitation::generateLabel is called 43 times > (fair enough), and that *each* of this calls scans the current buffer > for all the existing citation keys. > > Why are we doing something so stupid??
Ach, do Lieber Gott! This code *used* to be incredibly slow but then I introduced a hack to speed things up enormously. The problem is that it's extremely expensive to generate natbib-style labels because that requires the BibTeX database to be parsed. I introduced a cache that should be updated only when the BibTeX database is changed. Moreover, the generation code should not be called until an attempt is made to draw the label. Clearly, something is now going wrong but I hope this explanation of the mechanics helps you track down the problem. -- Angus