>> As far as I understood, there are links to macros stored in a table. >> This means that the table says that Macro_x is used in paragraph 10, >> position 12 etc. If the document changes, one has to adjust these >> numbers as the location might now be paragraph 11, position 12 after >> a new paragraph is inserted. >> > > But these links are only needed when a macro is changed, right? > Shouldn't the expensive operation (look over all files) be done on > this occasion only? > > >It seems to me that there are two (potential) problems. I've made >suggestions about this elsewhere in the other thread, but let me >repeat them here.
>(i) The filesystem checks that are causing the slowdown for Vincent >simply don't need to be done as often as they are. The checks are >generated by a call to loadIfNeeded(). It seems to me that there >are only a few occasions when a file could need to be loaded if it >wasn't already. E.g., initially; if an InsetInclude has been added >or modified; or if the default master has been changed; if a file >has been saved under a new name; if a buffer has been closed. So we >could have some flag, maybe in the BufferList, that meant: you don't >need to check this, nothing has changed. And it could be set and >cleared by e.g. InsetInclude constructors. I don't think there are >that many cases to consider. > >I'd be happy to work on at least the former, if the general idea >seems reasonable to people. > I might be a bit annoying, but let's pretend we don't know the problem with the filesystem checks. Then, how would you explain to someone that you're implementing administrative tools, touching many files and thinking of all different special cases with the risk you forget one, while you can find out whether a file is loaded just by looping over all buffers in the memory and comparing a handful of strings to each other. As I have said somewhere else, you can probably do very very many string comparisons before the user will notice. Although this will probably be a solution to my problem and it certainly seems reasonable, I'd would also like to see a FileName class that compares filenames (in a cross-platform way) that does not access the filesystem every time. >(ii) The updateMacros() call is probably being done too often, and >for similar reasons. It must be possible to have a better sense than >we apparently do of when it needs to be done, and set and clear a >flag that will tell us when it does need to be done. E.g., if a macro >is modified; if a paragraph is added or deleted; etc. We do this kind >of thing for lots of other purposes, e.g., the FitCursor stuff and the >drawing optimizations. First of all, there was a thread some time ago. In this thread Stefan has explained a bit why it was necessary and when: http://thread.gmane.org/gmane.editors.lyx.devel/114759 . I think I will investigate this point somewhat more. >rh Vincent
