From ecea7718010ad878954729385076c110b41a336b Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 17 May 2013 12:54:06 +0200 Subject: [PATCH] Making RTree's find more efficient By doing the type check before the intersection check, we can save he intersection check for cases where we don't care about type or have the specified type in a node. --- src/ol/structs/rtree.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/structs/rtree.js b/src/ol/structs/rtree.js index 39a0c8c643..b56164f527 100644 --- a/src/ol/structs/rtree.js +++ b/src/ol/structs/rtree.js @@ -59,8 +59,8 @@ ol.structs.RTreeNode_ = function(bounds, parent, level) { * @param {string=} opt_type Type for another indexing dimension. */ ol.structs.RTreeNode_.prototype.find = function(bounds, results, opt_type) { - if (ol.extent.intersects(this.bounds, bounds) && - (!goog.isDef(opt_type) || this.types[opt_type] === true)) { + if ((!goog.isDef(opt_type) || this.types[opt_type] === true) && + ol.extent.intersects(this.bounds, bounds)) { var numChildren = this.children.length; if (numChildren === 0) { if (goog.isDef(this.object)) {