Enrico Forestieri wrote:
On Sun, Nov 08, 2009 at 11:54:42AM +0100, Abdelrazak Younes wrote:
Wouldn't this lead to performance problem at first load of a document
with many macros? Ideally we only want to this once at file parsing and
then each time a new macro is created.
Yes, I was aware of this problem but don't know how to (easily) avoid it.
This call to updateMacros() is only needed at loading time, otherwise LyX
wouldn't know that a macro with a given name was already defined or not
by the user. One possibility that I took into account was tracking macro
creation in the parser itself. This would need adding a new std::set member
to the buffer (for example) in order to collect the macro names.
This would be fast, but then we would need a way to discriminate whether
the parser is called at loading time or not. Indeed, when checking for
the existence of a macro, we could simply check the std::set member at
loading time, but have to use getMacro() otherwise. This is because a
macro could be deleted later and getMacro() knows this. Hmmm... maybe
the std::set member could also be updated when that happens...
This definitely needs some more thinking... and time...
  I see... But I guess this fix will be important for some users...

I did that and now the loading time is as it was before using updateMacros().
Not a great deal, though. A document with about 150 macros now loads in
about 3-4 seconds against about 5-6. However, in percentage that is a
40%-50% speedup, which could be significant for slow storage media.

That's pretty significant indeed!

Thanks Enrico,

Abdel.

Reply via email to