From ce1ec3edd2f7ebd17050acdfc5be1f4798c80f45 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 24 Oct 2007 07:32:25 +0000 Subject: [PATCH] small optimization. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21166 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Text.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Text.cpp b/src/Text.cpp index d7b0355338..2c72eefdff 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -855,7 +855,8 @@ void Text::changeCase(Cursor & cur, Text::TextCase action) pos_type right = 0; // needed after the for loop for (pit_type pit = begPit; pit <= endPit; ++pit) { - pos_type parSize = pars_[pit].size(); + Paragraph & par = pars_[pit]; + pos_type parSize = par.size(); pos_type pos = (pit == begPit ? begPos : 0); right = (pit == endPit ? endPos : parSize); @@ -868,11 +869,11 @@ void Text::changeCase(Cursor & cur, Text::TextCase action) bool capitalize = true; for (; pos < right; ++pos) { - char_type oldChar = pars_[pit].getChar(pos); + char_type oldChar = par.getChar(pos); char_type newChar = oldChar; // ignore insets and don't play with deleted text! - if (pars_[pit].isInset(pos) && !pars_[pit].isDeleted(pos)) { + if (par.isInset(pos) && !par.isDeleted(pos)) { switch (action) { case text_lowercase: newChar = lowercase(oldChar); @@ -889,7 +890,7 @@ void Text::changeCase(Cursor & cur, Text::TextCase action) } } - if (!pars_[pit].isLetter(pos) || pars_[pit].isDeleted(pos)) { + if (!par.isLetter(pos) || par.isDeleted(pos)) { capitalize = true; // permit capitalization again } @@ -903,11 +904,11 @@ void Text::changeCase(Cursor & cur, Text::TextCase action) } int erasePos = pos - changes.size(); for (size_t i = 0; i < changes.size(); i++) { - pars_[pit].insertChar(pos, changes[i], - pars_[pit].getFontSettings(cur.buffer().params(), + par.insertChar(pos, changes[i], + par.getFontSettings(cur.buffer().params(), erasePos), trackChanges); - if (!pars_[pit].eraseChar(erasePos, trackChanges)) { + if (!par.eraseChar(erasePos, trackChanges)) { ++erasePos; ++pos; // advance ++right; // expand selection -- 2.39.2