From b5c6adc5fb5f6c2d625c682e31a376a5f07d17f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 12 Mar 2002 16:11:51 +0000 Subject: [PATCH] more streamlining git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3730 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_iterator.C | 33 +++++++++++++-------------------- src/mathed/math_iterator.h | 4 ---- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/mathed/math_iterator.C b/src/mathed/math_iterator.C index 7bb1845097..91e022bae4 100644 --- a/src/mathed/math_iterator.C +++ b/src/mathed/math_iterator.C @@ -39,25 +39,13 @@ MathInset * MathIterator::par() } -MathXArray const & MathIterator::xcell() const -{ - return par()->xcell(position().idx_); -} - - MathArray const & MathIterator::cell() const { - return par()->xcell(position().idx_).data_; + MathCursorPos const & top = position(); + return top.par_->cell(top.idx_); } -MathInset * MathIterator::nextInset() const -{ - if (position().pos_ == xcell().data_.size()) - return 0; - return (xcell().begin() + position().pos_)->nucleus(); -} - void MathIterator::push(MathInset * p) { @@ -88,24 +76,29 @@ MathCursorPos const & MathIterator::operator->() const void MathIterator::goEnd() { - position().idx_ = par()->nargs() - 1; - position().pos_ = xcell().data_.size(); + MathCursorPos & top = position(); + top.idx_ = top.par_->nargs() - 1; + top.pos_ = cell().size(); } void MathIterator::operator++() { + MathCursorPos & top = position(); + MathArray const & ar = top.par_->cell(top.idx_); + // move into the current inset if possible // it is impossible for pos() == size()! - MathInset * n = nextInset(); + MathInset * n = 0; + if (top.pos_ != ar.size()) + n = (ar.begin() + top.pos_)->nucleus(); if (n && n->isActive()) { push(n); return; } // otherwise move on one cell position if possible - MathCursorPos & top = position(); - if (top.pos_ < top.par_->cell(top.idx_).size()) { + if (top.pos_ < ar.size()) { // pos() == size() is valid! ++top.pos_; return; @@ -121,8 +114,8 @@ void MathIterator::operator++() // otherwise leave array, move on one position // this might yield pos() == size(), but that's a ok. - // it certainly invalidates top pop(); + // it certainly invalidates top ++position().pos_; } diff --git a/src/mathed/math_iterator.h b/src/mathed/math_iterator.h index 29998f4ac4..70fdef85c7 100644 --- a/src/mathed/math_iterator.h +++ b/src/mathed/math_iterator.h @@ -38,10 +38,6 @@ public: MathArray const & cell() const; private: - /// read access to top most item - MathXArray const & xcell() const; - /// write access to top most item - MathInset * nextInset() const; /// own level down void push(MathInset *); /// own level up -- 2.39.5