small optimization + namechange for getNextFold->getNextFoldLine

This commit is contained in:
nightwing 2011-10-16 17:06:01 +05:00
commit 70201ad6a7
4 changed files with 12 additions and 12 deletions

View file

@ -1457,7 +1457,7 @@ var EditSession = function(text, mode) {
// clamp row before clamping column, for selection on last line // clamp row before clamping column, for selection on last line
var maxRow = this.getLength() - 1; var maxRow = this.getLength() - 1;
var foldLine = this.getNextFold(docRow); var foldLine = this.getNextFoldLine(docRow);
var foldStart = foldLine ? foldLine.start.row : Infinity; var foldStart = foldLine ? foldLine.start.row : Infinity;
while (row <= screenRow) { while (row <= screenRow) {
@ -1469,7 +1469,7 @@ var EditSession = function(text, mode) {
docRow++; docRow++;
if (docRow > foldStart) { if (docRow > foldStart) {
docRow = foldLine.end.row+1; docRow = foldLine.end.row+1;
foldLine = this.getNextFold(docRow); foldLine = this.getNextFoldLine(docRow, foldLine);
foldStart = foldLine ? foldLine.start.row : Infinity; foldStart = foldLine ? foldLine.start.row : Infinity;
} }
} }
@ -1579,7 +1579,7 @@ var EditSession = function(text, mode) {
} }
var doCache = !rowCache.length || i == rowCache.length; var doCache = !rowCache.length || i == rowCache.length;
var foldLine = this.getNextFold(row); var foldLine = this.getNextFoldLine(row);
var foldStart = foldLine ?foldLine.start.row :Infinity; var foldStart = foldLine ?foldLine.start.row :Infinity;
while (row < docRow) { while (row < docRow) {
@ -1587,7 +1587,7 @@ var EditSession = function(text, mode) {
rowEnd = foldLine.end.row + 1; rowEnd = foldLine.end.row + 1;
if (rowEnd > docRow) if (rowEnd > docRow)
break; break;
foldLine = this.getNextFold(rowEnd); foldLine = this.getNextFoldLine(rowEnd, foldLine);
foldStart = foldLine ?foldLine.start.row :Infinity; foldStart = foldLine ?foldLine.start.row :Infinity;
} }
else { else {
@ -1713,4 +1713,4 @@ var EditSession = function(text, mode) {
require("ace/edit_session/folding").Folding.call(EditSession.prototype); require("ace/edit_session/folding").Folding.call(EditSession.prototype);
exports.EditSession = EditSession; exports.EditSession = EditSession;
}); });

View file

@ -183,7 +183,7 @@ function Folding() {
} }
// returns the fold which starts after or contains docRow // returns the fold which starts after or contains docRow
this.getNextFold = function(docRow, startFoldLine) { this.getNextFoldLine = function(docRow, startFoldLine) {
var foldData = this.$foldData, ans; var foldData = this.$foldData, ans;
var i = 0; var i = 0;
if (startFoldLine) if (startFoldLine)

View file

@ -103,13 +103,13 @@ var Gutter = function(parentEl) {
var html = []; var html = [];
var i = config.firstRow; var i = config.firstRow;
var lastRow = config.lastRow; var lastRow = config.lastRow;
var fold = this.session.getNextFold(i); var fold = this.session.getNextFoldLine(i);
var foldStart = fold ? fold.start.row : Infinity; var foldStart = fold ? fold.start.row : Infinity;
while (true) { while (true) {
if(i > foldStart) { if(i > foldStart) {
i = fold.end.row + 1; i = fold.end.row + 1;
fold = this.session.getNextFold(i); fold = this.session.getNextFoldLine(i, fold);
foldStart = fold ?fold.start.row :Infinity; foldStart = fold ?fold.start.row :Infinity;
} }
if(i > lastRow) if(i > lastRow)

View file

@ -260,13 +260,13 @@ var Text = function(parentEl) {
this.$renderLinesFragment = function(config, firstRow, lastRow) { this.$renderLinesFragment = function(config, firstRow, lastRow) {
var fragment = this.element.ownerDocument.createDocumentFragment(), var fragment = this.element.ownerDocument.createDocumentFragment(),
row = firstRow, row = firstRow,
fold = this.session.getNextFold(row), fold = this.session.getNextFoldLine(row),
foldStart = fold ?fold.start.row :Infinity; foldStart = fold ?fold.start.row :Infinity;
while (true) { while (true) {
if(row > foldStart) { if(row > foldStart) {
row = fold.end.row+1; row = fold.end.row+1;
fold = this.session.getNextFold(row); fold = this.session.getNextFoldLine(row, fold);
foldStart = fold ?fold.start.row :Infinity; foldStart = fold ?fold.start.row :Infinity;
} }
if(row > lastRow) if(row > lastRow)
@ -307,13 +307,13 @@ var Text = function(parentEl) {
var firstRow = config.firstRow, lastRow = config.lastRow; var firstRow = config.firstRow, lastRow = config.lastRow;
var row = firstRow, var row = firstRow,
fold = this.session.getNextFold(row), fold = this.session.getNextFoldLine(row),
foldStart = fold ?fold.start.row :Infinity; foldStart = fold ?fold.start.row :Infinity;
while (true) { while (true) {
if(row > foldStart) { if(row > foldStart) {
row = fold.end.row+1; row = fold.end.row+1;
fold = this.session.getNextFold(row); fold = this.session.getNextFoldLine(row, fold);
foldStart = fold ?fold.start.row :Infinity; foldStart = fold ?fold.start.row :Infinity;
} }
if(row > lastRow) if(row > lastRow)