mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Introduce a local cache to the getLyXText method for repetitive calls.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2167 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fff924cc29
commit
6687595f9c
@ -1,3 +1,11 @@
|
||||
2001-07-02 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insettext.C (getLyXText): introduce a cache in getLyXText so that
|
||||
following calls are only returned the right pointer without the over
|
||||
head to search in the map.
|
||||
(various funcs): reset the cached_bview variable as this signs that
|
||||
the cache is not valid anymore.
|
||||
|
||||
2001-06-29 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* insettabular.C (clone): do not copy the LyXTabular twice
|
||||
|
@ -111,6 +111,7 @@ void InsetText::init(InsetText const * ins)
|
||||
old_par = 0;
|
||||
last_drawn_width = -1;
|
||||
frame_is_visible = false;
|
||||
cached_bview = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -118,6 +119,7 @@ InsetText::~InsetText()
|
||||
{
|
||||
// delete all instances of LyXText before deleting the paragraps used
|
||||
// by it.
|
||||
cached_bview = 0;
|
||||
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
|
||||
delete (*cit).second;
|
||||
(*cit).second = 0;
|
||||
@ -135,6 +137,7 @@ void InsetText::clear()
|
||||
{
|
||||
// delete all instances of LyXText before deleting the paragraps used
|
||||
// by it.
|
||||
cached_bview = 0;
|
||||
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit) {
|
||||
delete (*cit).second;
|
||||
(*cit).second = 0;
|
||||
@ -1498,6 +1501,7 @@ void InsetText::setParagraphData(Paragraph * p)
|
||||
{
|
||||
// delete all instances of LyXText before deleting the paragraps used
|
||||
// by it.
|
||||
cached_bview = 0;
|
||||
for (Cache::iterator cit = cache.begin(); cit != cache.end(); ++cit){
|
||||
delete (*cit).second;
|
||||
(*cit).second = 0;
|
||||
@ -1613,28 +1617,34 @@ Row * InsetText::crow(BufferView * bv) const
|
||||
LyXText * InsetText::getLyXText(BufferView const * lbv,
|
||||
bool const recursive) const
|
||||
{
|
||||
if (!recursive && cached_bview && (cached_bview == lbv))
|
||||
return cached_text;
|
||||
|
||||
// Super UGLY! (Lgb)
|
||||
BufferView * bv = const_cast<BufferView *>(lbv);
|
||||
|
||||
cached_bview = bv;
|
||||
if ((cache.find(bv) != cache.end()) && cache[bv]) {
|
||||
cached_text = cache[bv];
|
||||
if (recursive && the_locking_inset)
|
||||
return the_locking_inset->getLyXText(bv);
|
||||
return cache[bv];
|
||||
return cached_text;
|
||||
}
|
||||
LyXText * lt = new LyXText(const_cast<InsetText *>(this));
|
||||
lt->init(bv);
|
||||
cache[bv] = lt;
|
||||
cached_text = new LyXText(const_cast<InsetText *>(this));
|
||||
cached_text->init(bv);
|
||||
cache[bv] = cached_text;
|
||||
if (the_locking_inset) {
|
||||
lt->setCursor(bv, inset_par, inset_pos, true, inset_boundary);
|
||||
cached_text->setCursor(bv, inset_par, inset_pos, true, inset_boundary);
|
||||
if (recursive)
|
||||
return the_locking_inset->getLyXText(bv);
|
||||
}
|
||||
return lt;
|
||||
return cached_text;
|
||||
}
|
||||
|
||||
|
||||
void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
|
||||
{
|
||||
cached_bview = 0;
|
||||
if ((cache.find(bv) == cache.end()) || !cache[bv])
|
||||
return;
|
||||
delete cache[bv];
|
||||
|
@ -322,5 +322,8 @@ private:
|
||||
mutable int last_drawn_width;
|
||||
///
|
||||
mutable bool frame_is_visible;
|
||||
///
|
||||
mutable BufferView * cached_bview;
|
||||
mutable LyXText * cached_text;
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user