Skip to content

Commit 09f6d44

Browse files
committed
Cache size of all lines except the last
1 parent 215a1c1 commit 09f6d44

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/utils.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ var utils = {
3434
},
3535

3636
calculateLineSize: function (line) {
37+
if (line.size) {
38+
return line.size;
39+
}
40+
3741
var size = { height: 1, width: 0 };
3842
line.forEach(function (outputEntry) {
3943
var outputEntrySize = utils.calculateOutputEntrySize(outputEntry);
@@ -46,10 +50,13 @@ var utils = {
4650

4751
calculateSize: function (lines) {
4852
var size = { height: 0, width: 0 };
49-
lines.forEach(function (line) {
53+
lines.forEach(function (line, index) {
5054
var lineSize = utils.calculateLineSize(line);
5155
size.height += lineSize.height;
5256
size.width = Math.max(size.width, lineSize.width);
57+
if (index < lines.length - 1) {
58+
line.size = lineSize;
59+
}
5360
});
5461
return size;
5562
},

0 commit comments

Comments
 (0)