Skip to content

Commit 9d772cd

Browse files
committed
reduce memory allocation in label build
1 parent 4bd959c commit 9d772cd

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

src/labels/label.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import PointAnchor from './point_anchor';
22
import {boxIntersectsList} from './intersect';
3-
import Utils from '../utils/utils';
43
import OBB from '../utils/obb';
54
import Geo from '../utils/geo';
65
// import log from '../utils/log';
@@ -79,13 +78,10 @@ export default class Label {
7978

8079
// checks whether the label is within the tile boundaries
8180
inTileBounds () {
82-
let min = [ this.aabb[0], this.aabb[1] ];
83-
let max = [ this.aabb[2], this.aabb[3] ];
84-
85-
if (!Utils.pointInTile(min) || !Utils.pointInTile(max)) {
81+
if ((this.aabb[0] >= 0 && this.aabb[1] > -Geo.tile_scale && this.aabb[0] < Geo.tile_scale && this.aabb[1] <= 0) ||
82+
(this.aabb[2] >= 0 && this.aabb[3] > -Geo.tile_scale && this.aabb[2] < Geo.tile_scale && this.aabb[3] <= 0)) {
8683
return false;
8784
}
88-
8985
return true;
9086
}
9187

src/utils/utils.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import log from './log';
55
import Thread from './thread';
66
import WorkerBroker from './worker_broker';
7-
import Geo from './geo';
87

98
export default Utils;
109

@@ -237,7 +236,3 @@ Utils.toCSSColor = function (color) {
237236
// RGB is between [0, 255] opacity is between [0, 1]
238237
return `rgba(${color.map((c, i) => (i < 3 && Math.round(c * 255)) || c).join(', ')})`;
239238
};
240-
241-
Utils.pointInTile = function (point) {
242-
return point[0] >= 0 && point[1] > -Geo.tile_scale && point[0] < Geo.tile_scale && point[1] <= 0;
243-
};

0 commit comments

Comments
 (0)