Saves exactly 20% for buffer switching and a bit more for UserGuide loading.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)
Index: paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.319
diff -u -p -r1.319 paragraph.C
--- paragraph.C 15 Sep 2003 10:59:52 -0000      1.319
+++ paragraph.C 16 Sep 2003 13:35:11 -0000
@@ -60,7 +60,7 @@ Paragraph::Paragraph()
 
 
 Paragraph::Paragraph(Paragraph const & lp)
-       : y(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
+       : y(0), text_(lp.text_), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
 {
        enumdepth = 0;
        itemdepth = 0;
@@ -87,6 +87,8 @@ void Paragraph::operator=(Paragraph cons
 
        lyxerr << "Paragraph::operator=()" << endl;
 
+       text_ = lp.text_;
+
        delete pimpl_;
        pimpl_ = new Pimpl(*lp.pimpl_, this);
 
@@ -1256,21 +1258,21 @@ void Paragraph::rejectChange(pos_type st
 }
 
 
-lyx::pos_type Paragraph::size() const
+Paragraph::value_type Paragraph::getChar(pos_type pos) const
 {
-       return pimpl_->size();
-}
+       // This is in the critical path!
+       pos_type const siz = text_.size();
 
+       BOOST_ASSERT(pos <= siz);
 
-bool Paragraph::empty() const
-{
-       return pimpl_->empty();
-}
-
+       if (pos == siz) {
+               lyxerr << "getChar() on pos " << pos << " in par id "
+                      << id() << " of size " << siz
+                      << "  is a bit silly !" << endl;
+               return '\0';
+       }
 
-Paragraph::value_type Paragraph::getChar(pos_type pos) const
-{
-       return pimpl_->getChar(pos);
+       return text_[pos];
 }
 
 
@@ -1311,12 +1313,13 @@ UpdatableInset * Paragraph::inInset() co
 
 void Paragraph::clearContents()
 {
-       pimpl_->clear();
+       text_.clear();
 }
 
+
 void Paragraph::setChar(pos_type pos, value_type c)
 {
-       pimpl_->setChar(pos, c);
+       text_[pos] = c;
 }
 
 
Index: paragraph.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.h,v
retrieving revision 1.103
diff -u -p -r1.103 paragraph.h
--- paragraph.h 6 Sep 2003 18:38:01 -0000       1.103
+++ paragraph.h 16 Sep 2003 13:35:11 -0000
@@ -56,6 +56,8 @@ public:
        typedef char value_type;
        ///
        typedef lyx::depth_type depth_type;
+       ///
+       typedef std::vector<value_type> TextContainer;
 
        ///
        Paragraph();
@@ -120,9 +122,9 @@ public:
        void deleteInsetsLyXText(BufferView *);
 
        ///
-       lyx::pos_type size() const;
+       lyx::pos_type size() const { return text_.size(); }
        ///
-       bool empty() const;
+       bool empty() const { return text_.empty(); }
        ///
        void setContentsFromPar(Paragraph const & par);
        ///
@@ -308,6 +310,8 @@ public:
 private:
        ///
        LyXLayout_ptr layout_;
+       ///
+       TextContainer text_;
 
        struct Pimpl;
        ///
Index: paragraph_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_pimpl.C,v
retrieving revision 1.83
diff -u -p -r1.83 paragraph_pimpl.C
--- paragraph_pimpl.C   16 Sep 2003 09:44:30 -0000      1.83
+++ paragraph_pimpl.C   16 Sep 2003 13:35:11 -0000
@@ -72,7 +72,6 @@ Paragraph::Pimpl::Pimpl(Pimpl const & p,
        : params(p.params), owner_(owner)
 {
        inset_owner = p.inset_owner;
-       text = p.text;
        fontlist = p.fontlist;
        id_ = paragraph_id++;
 
@@ -81,16 +80,9 @@ Paragraph::Pimpl::Pimpl(Pimpl const & p,
 }
 
 
-void Paragraph::Pimpl::clear()
-{
-       text.clear();
-#warning changes ?
-}
-
-
 void Paragraph::Pimpl::setContentsFromPar(Paragraph const & par)
 {
-       text = par.pimpl_->text;
+       owner_->text_ = par.text_;
        if (par.pimpl_->tracking()) {
                changes_.reset(new Changes(*(par.pimpl_->changes_.get())));
        }
@@ -256,31 +248,7 @@ void Paragraph::Pimpl::rejectChange(pos_
 
 Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
 {
-#if 1
-       // This is in the critical path for loading!
-       pos_type const siz = size();
-
-       BOOST_ASSERT(pos <= siz);
-
-       if (pos == siz) {
-               lyxerr << "getChar() on pos " << pos << " in par id "
-                      << owner_->id() << " of size " << siz
-                      << "  is a bit silly !" << endl;
-               return '\0';
-       }
-
-       return text[pos];
-#else
-       BOOST_ASSERT(pos < size());
-       return text[pos];
-#endif
-}
-
-
-void Paragraph::Pimpl::setChar(pos_type pos, value_type c)
-{
-#warning changes
-       text[pos] = c;
+       return owner_->getChar(pos);
 }
 
 
@@ -297,12 +265,12 @@ void Paragraph::Pimpl::insertChar(pos_ty
        // maybe inserting ascii text)
        if (pos == size()) {
                // when appending characters, no need to update tables
-               text.push_back(c);
+               owner_->text_.push_back(c);
                owner_->setFont(pos, font);
                return;
        }
 
-       text.insert(text.begin() + pos, c);
+       owner_->text_.insert(owner_->text_.begin() + pos, c);
 
        // Update the font table.
        FontTable search_font(pos, LyXFont());
@@ -328,7 +296,7 @@ void Paragraph::Pimpl::insertInset(pos_t
        BOOST_ASSERT(pos <= size());
 
        insertChar(pos, META_INSET, font, change);
-       BOOST_ASSERT(text[pos] == META_INSET);
+       BOOST_ASSERT(owner_->text_[pos] == META_INSET);
 
        // Add a new entry in the insetlist.
        owner_->insetlist.insert(inset, pos);
@@ -341,11 +309,11 @@ void Paragraph::Pimpl::insertInset(pos_t
 void Paragraph::Pimpl::eraseIntern(pos_type pos)
 {
        // if it is an inset, delete the inset entry
-       if (text[pos] == Paragraph::META_INSET) {
+       if (owner_->text_[pos] == Paragraph::META_INSET) {
                owner_->insetlist.erase(pos);
        }
 
-       text.erase(text.begin() + pos);
+       owner_->text_.erase(owner_->text_.begin() + pos);
 
        // Erase entries in the tables.
        FontTable search_font(pos, LyXFont());
@@ -392,7 +360,7 @@ bool Paragraph::Pimpl::erase(pos_type po
 
                // only allow the actual removal if it was /new/ text
                if (changetype != Change::INSERTED) {
-                       if (text[pos] == Paragraph::META_INSET) {
+                       if (owner_->text_[pos] == Paragraph::META_INSET) {
                                InsetOld * i(owner_->getInset(pos));
                                i->markErased();
                        }
@@ -463,7 +431,7 @@ bool Paragraph::Pimpl::isTextAt(string c
 
        // does the wanted text start at point?
        for (string::size_type i = 0; i < str.length(); ++i) {
-               if (str[i] != text[pos + i])
+               if (str[i] != owner_->text_[pos + i])
                        return false;
        }
 
Index: paragraph_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph_pimpl.h,v
retrieving revision 1.37
diff -u -p -r1.37 paragraph_pimpl.h
--- paragraph_pimpl.h   7 Sep 2003 01:45:37 -0000       1.37
+++ paragraph_pimpl.h   16 Sep 2003 13:35:11 -0000
@@ -26,23 +26,10 @@ class LyXLayout;
 
 struct Paragraph::Pimpl {
        ///
-       typedef std::vector<value_type> TextContainer;
-
-       ///
        Pimpl(Paragraph * owner);
        /// Copy constructor
        Pimpl(Pimpl const &, Paragraph * owner);
        ///
-       lyx::pos_type size() const {
-               return text.size();
-       }
-       ///
-       bool empty() const {
-               return text.empty();
-       }
-       ///
-       void clear();
-       ///
        void setContentsFromPar(Paragraph const & par);
        /// set tracking mode
        void trackChanges(Change::Type type = Change::UNCHANGED);
@@ -182,6 +169,8 @@ struct Paragraph::Pimpl {
        ParagraphParameters params;
 
 private:
+       ///
+       lyx::pos_type size() const { return owner_->size(); }
        /// match a string against a particular point in the paragraph
        bool isTextAt(string const & str, lyx::pos_type pos) const;
 
@@ -190,8 +179,6 @@ private:
 
        /// Who owns us?
        Paragraph * owner_;
-       ///
-       TextContainer text;
 };
 
 #endif

Reply via email to