Am 17.01.2009 um 14:44 schrieb Andre Poenitz:

On Sat, Jan 17, 2009 at 12:50:46PM +0100, Vincent van Ravesteijn wrote:
For every letter I type in LyX, the updateMacros() function is called
from BufferView::processUpdateFlags().

What does this function do ? The only feature I see is that when
changing a math-macro, all uses of the macro are updated.

I think so, too. Stefan might have authorative answers, though.

The name updateMacros is a bit misleading. We should better call it collectMacros of updateMacroTables or similar. It takes all the macro definitions in the buffer and stores them for later lookup, together with their position in the buffer. This information is essential to resolve a macro instance somewhere in the text. You can ask the buffer which macro definition belongs to \foo at paragraph 21, position 42. The buffer will tell you in logarithmic time (in the number of macros).

Probably one could improve the speed here by caching this information in paragraphs, or by marking those paragraphs which have macro definitions. Then we only have to update the lookup maps in the buffer when the paragraphs are moved around, e.g. by inserting a new paragraph. At least the whole updating is not done for every new character.

Stefan



Is it really necessary to do this always ? As it is in a "nearly hot
path" it took 44% of the time it took to process the insertion of a
character in the User's Guide.

This function even takes longer when you have child documents as it
iterates through all child documents too.

Maybe this is one of the reasons for all the bugs on slowness:
http://bugzilla.lyx.org/show_bug.cgi?id=5680

Do I miss something critical or is it ok to start cutting some paths ?

I would expect that there cannot be much harm done outside math.

Andre'

Reply via email to