Create geometryWidths array only when needed

This commit is contained in:
Guillaume Beraudo
2018-11-15 18:23:47 +01:00
parent 94bf02176e
commit b1a5f4855f
+6 -5
View File
@@ -194,7 +194,10 @@ class CanvasTextBuilder extends CanvasInstructionsBuilder {
} else { } else {
const geometryWidths = []; let geometryWidths = null;
if (!textState.overflow) {
geometryWidths = [];
}
switch (geometryType) { switch (geometryType) {
case GeometryType.POINT: case GeometryType.POINT:
case GeometryType.MULTI_POINT: case GeometryType.MULTI_POINT:
@@ -264,8 +267,7 @@ class CanvasTextBuilder extends CanvasInstructionsBuilder {
}), }),
!!textState.backgroundFill, !!textState.backgroundStroke, !!textState.backgroundFill, !!textState.backgroundStroke,
this.text_, this.textKey_, this.strokeKey_, this.fillKey_, this.text_, this.textKey_, this.strokeKey_, this.fillKey_,
this.textOffsetX_, this.textOffsetY_, this.textOffsetX_, this.textOffsetY_, geometryWidths
geometryWidths.length > 0 ? geometryWidths : null
]); ]);
this.hitDetectionInstructions.push([CanvasInstruction.DRAW_IMAGE, begin, end, this.hitDetectionInstructions.push([CanvasInstruction.DRAW_IMAGE, begin, end,
null, Infinity, Infinity, this.declutterGroup_, Infinity, 1, 0, 0, null, Infinity, Infinity, this.declutterGroup_, Infinity, 1, 0, 0,
@@ -273,8 +275,7 @@ class CanvasTextBuilder extends CanvasInstructionsBuilder {
textState.padding, textState.padding,
!!textState.backgroundFill, !!textState.backgroundStroke, !!textState.backgroundFill, !!textState.backgroundStroke,
this.text_, this.textKey_, this.strokeKey_, this.fillKey_, this.text_, this.textKey_, this.strokeKey_, this.fillKey_,
this.textOffsetX_, this.textOffsetY_, this.textOffsetX_, this.textOffsetY_, geometryWidths
geometryWidths.length > 0 ? geometryWidths : null
]); ]);
this.endGeometry(geometry, feature); this.endGeometry(geometry, feature);