[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kate/buffer
From: Christoph Cullmann <cullmann () kde ! org>
Date: 2010-11-06 18:35:05
Message-ID: 20101106183505.2D05EAC89E () svn ! kde ! org
[Download RAW message or body]
SVN commit 1193680 by cullmann:
mwolff:
opt: use non-detaching .at() instead of operator[]
M +16 -15 katetextblock.cpp
--- trunk/KDE/kdelibs/kate/buffer/katetextblock.cpp #1193679:1193680
@@ -59,7 +59,7 @@
Q_ASSERT (line < m_lines.size ());
// get text line
- return m_lines[line];
+ return m_lines.at(line);
}
void TextBlock::text (QString &text) const
@@ -70,7 +70,7 @@
if (i > 0 || startLine() > 0)
text.append ('\n');
- text.append (m_lines[i]->text ());
+ text.append (m_lines.at(i)->text ());
}
}
@@ -80,7 +80,7 @@
int line = position.line () - startLine ();
// get text
- QString &text = m_lines[line]->textReadWrite ();
+ QString &text = m_lines.at(line)->textReadWrite ();
// check if valid column
Q_ASSERT (position.column() >= 0);
@@ -92,7 +92,7 @@
// perhaps remove some text from previous line and append it
if (position.column() < text.size ()) {
// text from old line moved first to new one
- m_lines[line+1]->textReadWrite() = text.right (text.size() - position.column());
+ m_lines.at(line+1)->textReadWrite() = text.right (text.size() - position.column());
// now remove wrapped text from old line
text.chop (text.size() - position.column());
@@ -166,14 +166,15 @@
Q_ASSERT (previousBlock->lines () > 0);
// move last line of previous block to this one, might result in empty block
- TextLine oldFirst = m_lines[0];
+ TextLine oldFirst = m_lines.at(0);
int lastLineOfPreviousBlock = previousBlock->lines ()-1;
- m_lines[0] = previousBlock->m_lines.last();
+ TextLine newFirst = previousBlock->m_lines.last();
+ m_lines[0] = newFirst;
previousBlock->m_lines.erase (previousBlock->m_lines.begin() + (previousBlock->lines () - 1));
// append text
- int oldSizeOfPreviousLine = m_lines[0]->text().size();
- m_lines[0]->textReadWrite().append (oldFirst->text());
+ int oldSizeOfPreviousLine = newFirst->text().size();
+ newFirst->textReadWrite().append (oldFirst->text());
// patch startLine of this block
--m_startLine;
@@ -243,8 +244,8 @@
}
// easy: just move text to previous line and remove current one
- int oldSizeOfPreviousLine = m_lines[line-1]->text().size();
- m_lines[line-1]->textReadWrite().append (m_lines[line]->text());
+ int oldSizeOfPreviousLine = m_lines.at(line-1)->text().size();
+ m_lines.at(line-1)->textReadWrite().append (m_lines.at(line)->text());
m_lines.erase (m_lines.begin () + line);
/**
@@ -293,7 +294,7 @@
int line = position.line () - startLine ();
// get text
- QString &textOfLine = m_lines[line]->textReadWrite ();
+ QString &textOfLine = m_lines.at(line)->textReadWrite ();
int oldLength = textOfLine.size ();
// check if valid column
@@ -354,7 +355,7 @@
int line = range.start().line () - startLine ();
// get text
- QString &textOfLine = m_lines[line]->textReadWrite ();
+ QString &textOfLine = m_lines.at(line)->textReadWrite ();
int oldLength = textOfLine.size ();
// check if valid column
@@ -415,7 +416,7 @@
// print all blocks
for (int i = 0; i < m_lines.size(); ++i)
printf ("%4d - %4d : %4d : '%s'\n", blockIndex, startLine() + i
- , m_lines[i]->text().size(), qPrintable (m_lines[i]->text()));
+ , m_lines.at(i)->text().size(), qPrintable (m_lines.at(i)->text()));
}
TextBlock *TextBlock::splitBlock (int fromLine)
@@ -429,7 +430,7 @@
// move lines
newBlock->m_lines.reserve (linesOfNewBlock);
for (int i = fromLine; i < m_lines.size(); ++i)
- newBlock->m_lines.append (m_lines[i]);
+ newBlock->m_lines.append (m_lines.at(i));
m_lines.resize (fromLine);
// move cursors
@@ -474,7 +475,7 @@
// move lines
targetBlock->m_lines.reserve (targetBlock->lines() + lines ());
for (int i = 0; i < m_lines.size(); ++i)
- targetBlock->m_lines.append (m_lines[i]);
+ targetBlock->m_lines.append (m_lines.at(i));
m_lines.clear ();
QList<TextRange*> allRanges = m_uncachedRanges.toList() + m_cachedLineForRanges.keys();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic