IDEA-69317 Editor: Improve performance

Minor improvements to soft wraps recalculation
This commit is contained in:
Denis Zhdanov
2011-06-20 12:40:52 +04:00
parent 725e2b511b
commit 5ec316d268
2 changed files with 18 additions and 5 deletions
@@ -180,13 +180,22 @@ class CacheEntry implements Comparable<CacheEntry>, Cloneable {
myTabPositions.add(tabData);
}
@SuppressWarnings("ForLoopReplaceableByForEach")
public void advance(final int offsetDiff) {
startOffset += offsetDiff;
endOffset += offsetDiff;
for (TabData tabData : myTabPositions) {
tabData.offset += offsetDiff;
// 'For-each' loop is not used here because this code is called quite often and profile shows the Iterator usage here
// produces performance drawback.
for (int i = 0; i < myTabPositions.size(); i++) {
myTabPositions.get(i).offset += offsetDiff;
}
final TIntObjectHashMap<FoldingData> newFoldingData = new TIntObjectHashMap<FoldingData>();
if (myFoldingData.isEmpty()) {
return;
}
final TIntObjectHashMap<FoldingData> newFoldingData = new TIntObjectHashMap<FoldingData>(myFoldingData.size());
myFoldingData.forEachEntry(new TIntObjectProcedure<FoldingData>() {
@Override
public boolean execute(int offset, FoldingData foldingData) {
@@ -542,6 +542,7 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
* </ol>
</pre>
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
private void applyStateChange(int offsetsDiff) {
if (myNotAffectedByUpdateTailCacheEntries.isEmpty()) {
return;
@@ -565,7 +566,10 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
offsetsDiff));
}
for (CacheEntry cacheEntry : myNotAffectedByUpdateTailCacheEntries) {
// 'For-each' loop is not used here because this code is called quite often and profile shows the Iterator usage here
// produces performance drawback.
for (int i = 0; i < myNotAffectedByUpdateTailCacheEntries.size(); i++) {
CacheEntry cacheEntry = myNotAffectedByUpdateTailCacheEntries.get(i);
cacheEntry.visualLine += visualLinesDiff;
cacheEntry.startLogicalLine += logicalLinesDiff;
cacheEntry.endLogicalLine += logicalLinesDiff;
@@ -574,7 +578,7 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
cacheEntry.endSoftWrapLinesBefore += softWrappedLinesDiff;
cacheEntry.startFoldedLines += foldedLinesDiff;
cacheEntry.endFoldedLines += foldedLinesDiff;
}
}
}
@Override