[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:
| I'l like this patch to go in, Jürgen.
|
| ? build
| Index: src/insets/insettext.C
| ===================================================================
| RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
| retrieving revision 1.160
| diff -u -p -r1.160 insettext.C
| --- src/insets/insettext.C 2001/07/02 15:29:23 1.160
| +++ src/insets/insettext.C 2001/07/02 16:58:39
| @@ -1617,26 +1617,35 @@ Row * InsetText::crow(BufferView * bv) c
| LyXText * InsetText::getLyXText(BufferView const * lbv,
| bool const recursive) const
| {
| - if (!recursive && cached_bview && (cached_bview == lbv))
| + if (!recursive && (cached_bview == lbv))
| return cached_text;
should really not be needed to check cached_bview for != 0, we are
just comparing two pointers, not dereferencing any.
| // 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)
| + Cache::iterator it = cache.find(bv);
by using the iterator we reduce the number of lookups performed.
| +
| + if (it != cache.end()) {
| + lyx::Assert(it->second);
and we actually require that what we store in the cache has LyXText != 0
| + cached_text = it->second;
| + if (recursive && the_locking_inset) {
| return the_locking_inset->getLyXText(bv);
| + }
| return cached_text;
| }
| cached_text = new LyXText(const_cast<InsetText *>(this));
| cached_text->init(bv);
| - cache[bv] = cached_text;
| +
| + cache.insert(make_pair(bv, cached_text));
insert is a bit faster than [] since we don't have to default
construct an object first.
Similar for deleteLyXText and (in a limited degree) resizeLyXText.
--
Lgb