Abdelrazak Younes wrote:

> Abdelrazak Younes wrote:
>> Jürgen Spitzmüller wrote:
>>> The only case where it doesn't work is if you close and reopen a file
>>> without closing LyX, but this is unrelated to your patch (maybe you
>>> have an idea nevertheless?)
>> 
>> Does natbib support code uses some static global variable?
> 
> And this one:
> 
> // Cache the labels
> typedef std::map<Buffer const *, biblio::InfoMap> CachedMap;
> static CachedMap cached_keys;
> 
> Did I say already that static variables are evil?

The problem here is that getting these labels can be _very_ expensive (up to
20 seconds or more), so they must be cached. Of course a Buffer const * as
key is asking for trouble, but if you would use e.g. the filename I don't
see any problem with this static cache. Not all static variables are evil,
sometimes they are exactly the right tool for the right job.
Getting the labels can take that long because kpsewhich can be called
several times, and if you have a TeX installation with many files it can
really be slooooow.
Please keep this in mind when changing the natbib label code.


Georg

Reply via email to