Andre Poenitz wrote: > On Tue, Sep 16, 2003 at 10:19:07AM +0200, Alfredo Braunstein wrote: >> This patch avoids doing a full rebreak on buffer switching, which is the >> reason for the existence of the TextCache. >> The removed full rebreak is unneeded: it is done in every case (except >> from buffer switching) above in the same function. >> >> The update seems also to be unneeded, as caller functions do it anyways. >> >> The fact that this has gone unnoticed maybe raises a question on the >> usefullness of the TextCache? > > I don't think it is needed anymore. > > [I think it was just there to cure the symptoms of a slow full rebreak > in a 'recursive update world'. If we ever run in such a problem again we > should make the rebreak faster, not use a cache.] > > I would be glad if you tried to remove the TextCach entirely. > > Andre'
4 files changed, 4 insertions(+), 69 deletions(-) That would be it, less 256 lines of TextCache.[Ch] As said before (on the wrong list) there's no performance difference with current cvs (because a bug in there). But a current full rebreak on buffer switching is almost unnoticeable on today's hardware and acceptable on old one IMHO. Alfredo Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.437 diff -u -p -u -r1.437 BufferView_pimpl.C --- BufferView_pimpl.C 12 Sep 2003 17:13:18 -0000 1.437 +++ BufferView_pimpl.C 16 Sep 2003 08:53:49 -0000 @@ -40,7 +40,6 @@ #include "paragraph.h" #include "paragraph_funcs.h" #include "ParagraphParameters.h" -#include "TextCache.h" #include "undo_funcs.h" #include "vspace.h" @@ -295,14 +294,7 @@ void BufferView::Pimpl::buffer(Buffer * << b << ')' << endl; if (buffer_) { disconnectBuffer(); - // Put the old text into the TextCache, but - // only if the buffer is still loaded. - // Also set the owner of the test to 0 - // bv_->text->owner(0); - textcache.add(buffer_, workarea().workWidth(), bv_->text); - if (lyxerr.debugging()) - textcache.show(lyxerr, "BufferView::buffer"); - + delete bv_->text; bv_->text = 0; } @@ -337,13 +329,6 @@ void BufferView::Pimpl::buffer(Buffer * } else { lyxerr[Debug::INFO] << " No Buffer!" << endl; owner_->getDialogs().hideBufferDependent(); - - // Also remove all remaining text's from the testcache. - // (there should not be any!) (if there is any it is a - // bug!) - if (lyxerr.debugging()) - textcache.show(lyxerr, "buffer delete all"); - textcache.clear(); } update(); @@ -428,37 +413,15 @@ void BufferView::Pimpl::resizeCurrentBuf mark_set = bv_->text->selection.mark(); the_locking_inset = bv_->theLockingInset(); bv_->text->fullRebreak(); - update(); } else { - lyxerr << "text not available!" << endl; - // See if we have a text in TextCache that fits - // the new buffer_ with the correct width. - bv_->text = textcache.findFit(buffer_, workarea().workWidth()); - if (bv_->text) { - lyxerr << "text in cache!" << endl; - if (lyxerr.debugging()) { - lyxerr << "Found a LyXText that fits:" << endl; - textcache.show(lyxerr, make_pair(buffer_, make_pair(workarea().workWidth(), bv_->text))); - } - // Set the owner of the newly found text - // bv_->text->owner(bv_); - if (lyxerr.debugging()) - textcache.show(lyxerr, "resizeCurrentBuffer"); - } else { - lyxerr << "no text in cache!" << endl; - bv_->text = new LyXText(bv_, 0, false, bv_->buffer()->paragraphs()); - bv_->text->init(bv_); - } - + bv_->text = new LyXText(bv_, 0, false, + bv_->buffer()->paragraphs()); + bv_->text->init(bv_); par = bv_->text->ownerParagraphs().end(); selstartpar = bv_->text->ownerParagraphs().end(); selendpar = bv_->text->ownerParagraphs().end(); } -#warning does not help much - bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(), - bv_->text->ownerParagraphs().end()); - if (par != bv_->text->ownerParagraphs().end()) { bv_->text->selection.set(true); // At this point just to avoid the Delete-Empty-Paragraph- @@ -631,16 +594,6 @@ void BufferView::Pimpl::workAreaResize() if (widthChange) { // The visible LyXView need a resize resizeCurrentBuffer(); - - // Remove all texts from the textcache - // This is not _really_ what we want to do. What - // we really want to do is to delete in textcache - // that does not have a BufferView with matching - // width, but as long as we have only one BufferView - // deleting all gives the same result. - if (lyxerr.debugging()) - textcache.show(lyxerr, "Expose delete all"); - textcache.clear(); } } Index: Makefile.am =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/Makefile.am,v retrieving revision 1.191 diff -u -p -u -r1.191 Makefile.am --- Makefile.am 9 Sep 2003 23:10:07 -0000 1.191 +++ Makefile.am 16 Sep 2003 08:53:49 -0000 @@ -102,8 +102,6 @@ lyx_SOURCES = \ ShareContainer.h \ Spacing.C \ Spacing.h \ - TextCache.C \ - TextCache.h \ Thesaurus.C \ Thesaurus.h \ ToolbarBackend.C \ Index: bufferlist.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.C,v retrieving revision 1.133 diff -u -p -u -r1.133 bufferlist.C --- bufferlist.C 9 Sep 2003 22:13:23 -0000 1.133 +++ bufferlist.C 16 Sep 2003 08:53:49 -0000 @@ -21,7 +21,6 @@ #include "lyx_cb.h" #include "lyx_main.h" #include "paragraph.h" -#include "TextCache.h" #include "frontends/Alert.h" @@ -118,12 +117,8 @@ void BufferList::release(Buffer * buf) BOOST_ASSERT(buf); BufferStorage::iterator it = find(bstore.begin(), bstore.end(), buf); if (it != bstore.end()) { - // Make sure that we don't store a LyXText in - // the textcache that points to the buffer - // we just deleted. Buffer * tmp = (*it); bstore.erase(it); - textcache.removeAllWithBuffer(tmp); delete tmp; } } @@ -142,10 +137,6 @@ Buffer * BufferList::newBuffer(string co void BufferList::closeAll() { - // Since we are closing we can just as well delete all - // in the textcache this will also speed the closing/quiting up a bit. - textcache.clear(); - while (!bstore.empty()) { close(bstore.front(), false); } Index: lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.502 diff -u -p -u -r1.502 lyxfunc.C --- lyxfunc.C 12 Sep 2003 17:13:19 -0000 1.502 +++ lyxfunc.C 16 Sep 2003 08:53:52 -0000 @@ -46,7 +46,6 @@ #include "lyxvc.h" #include "paragraph.h" #include "ParagraphParameters.h" -#include "TextCache.h" #include "undo_funcs.h" #include "insets/insetcommand.h" @@ -1576,12 +1575,6 @@ void LyXFunc::dispatch(FuncRequest const // handle the screen font changes. lyxrc.set_font_norm_type(); lyx_gui::update_fonts(); - // We also need to empty the textcache so that - // the buffer will be formatted correctly after - // a zoom change. - textcache.clear(); - // Of course we should only do the resize and the textcache.clear - // if values really changed...but not very important right now. (Lgb) // All visible buffers will need resize view()->resize(); view()->update();