Do not recalculate additionalWidth on every line of multiline text

This is just a minor improvement (optimization) to _setTextData():
Flag shouldAddEllipsis is not changed inside the loop, thus no need
to recalculate the value of additionalWidth for every line of the
original text.
This commit is contained in:
VladimirTechMan 2019-01-08 20:03:25 +03:00
parent adcd6b9c96
commit 6c53a2b27a

View File

@ -356,11 +356,11 @@ export class Text extends Shape {
this.textArr = []; this.textArr = [];
getDummyContext().font = this._getContextFont(); getDummyContext().font = this._getContextFont();
var additionalWidth = shouldAddEllipsis
? this._getTextWidth(ELLIPSIS)
: 0;
for (var i = 0, max = lines.length; i < max; ++i) { for (var i = 0, max = lines.length; i < max; ++i) {
var line = lines[i]; var line = lines[i];
var additionalWidth = shouldAddEllipsis
? this._getTextWidth(ELLIPSIS)
: 0;
var lineWidth = this._getTextWidth(line); var lineWidth = this._getTextWidth(line);
if (fixedWidth && lineWidth > maxWidth) { if (fixedWidth && lineWidth > maxWidth) {