From b3b31ea16d033f318544e05de0a0909fcced8c68 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 27 Sep 2015 10:51:03 -0600 Subject: [PATCH] Inline various goog.isDef() calls --- src/ol/graticule.js | 4 ++-- src/ol/imagetile.js | 2 +- src/ol/proj/proj.js | 2 +- src/ol/render/canvas/canvasreplay.js | 8 +++++--- src/ol/render/webgl/webglreplay.js | 7 ++++--- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ol/graticule.js b/src/ol/graticule.js index 4d5b012042..10b76a8470 100644 --- a/src/ol/graticule.js +++ b/src/ol/graticule.js @@ -346,7 +346,7 @@ ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat, minLat, maxLat, this.projection_, squaredTolerance); goog.asserts.assert(flatCoordinates.length > 0, 'flatCoordinates cannot be empty'); - var lineString = goog.isDef(this.meridians_[index]) ? + var lineString = this.meridians_[index] !== undefined ? this.meridians_[index] : new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); return lineString; @@ -382,7 +382,7 @@ ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, this.minLon_, this.maxLon_, this.projection_, squaredTolerance); goog.asserts.assert(flatCoordinates.length > 0, 'flatCoordinates cannot be empty'); - var lineString = goog.isDef(this.parallels_[index]) ? + var lineString = this.parallels_[index] !== undefined ? this.parallels_[index] : new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); return lineString; diff --git a/src/ol/imagetile.js b/src/ol/imagetile.js index 60e7730387..3b893b58df 100644 --- a/src/ol/imagetile.js +++ b/src/ol/imagetile.js @@ -126,7 +126,7 @@ ol.ImageTile.prototype.handleImageError_ = function() { */ ol.ImageTile.prototype.handleImageLoad_ = function() { if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { - if (!goog.isDef(this.image_.naturalWidth)) { + if (this.image_.naturalWidth === undefined) { this.image_.naturalWidth = this.image_.width; this.image_.naturalHeight = this.image_.height; } diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 47b209dff2..b79aadfefb 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -146,7 +146,7 @@ ol.proj.Projection = function(options) { goog.asserts.assert(code !== undefined, 'Option "code" is required for constructing instance'); if (ol.ENABLE_PROJ4JS && typeof proj4 == 'function' && - !goog.isDef(projections[code])) { + projections[code] === undefined) { var def = proj4.defs(code); if (def !== undefined) { if (def.axis !== undefined && options.axisOrientation === undefined) { diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index a3a44356d3..f5805b5f25 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -257,11 +257,12 @@ ol.render.canvas.Replay.prototype.replay_ = function( case ol.render.canvas.Instruction.BEGIN_GEOMETRY: feature = /** @type {ol.Feature} */ (instruction[1]); var featureUid = goog.getUid(feature).toString(); - if (goog.isDef(skippedFeaturesHash[featureUid]) || + if (skippedFeaturesHash[featureUid] !== undefined || !goog.isDefAndNotNull(feature.getGeometry())) { i = /** @type {number} */ (instruction[2]); } else if (opt_hitExtent !== undefined && !ol.extent.intersects( - opt_hitExtent, feature.getGeometry().getExtent())) { + /** @type {Array} */ (opt_hitExtent), + feature.getGeometry().getExtent())) { i = /** @type {number} */ (instruction[2]); } else { ++i; @@ -451,7 +452,8 @@ ol.render.canvas.Replay.prototype.replay_ = function( '6th instruction should be a number'); goog.asserts.assert(!goog.isNull(instruction[6]), '7th instruction should not be null'); - var usePixelRatio = goog.isDef(instruction[7]) ? instruction[7] : true; + var usePixelRatio = instruction[7] !== undefined ? + instruction[7] : true; var lineWidth = /** @type {number} */ (instruction[2]); context.strokeStyle = /** @type {string} */ (instruction[1]); context.lineWidth = usePixelRatio ? lineWidth * pixelRatio : lineWidth; diff --git a/src/ol/render/webgl/webglreplay.js b/src/ol/render/webgl/webglreplay.js index b450e650db..b5ef477371 100644 --- a/src/ol/render/webgl/webglreplay.js +++ b/src/ol/render/webgl/webglreplay.js @@ -733,7 +733,7 @@ ol.render.webgl.ImageReplay.prototype.drawReplaySkipping_ = var feature = this.startIndicesFeature_[featureIndex]; var featureUid = goog.getUid(feature).toString(); - if (goog.isDef(skippedFeaturesHash[featureUid])) { + if (skippedFeaturesHash[featureUid] !== undefined) { // feature should be skipped if (start !== end) { // draw the features so far @@ -865,10 +865,11 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ = feature = this.startIndicesFeature_[featureIndex]; featureUid = goog.getUid(feature).toString(); - if (!goog.isDef(skippedFeaturesHash[featureUid]) && + if (skippedFeaturesHash[featureUid] === undefined && goog.isDefAndNotNull(feature.getGeometry()) && (opt_hitExtent === undefined || ol.extent.intersects( - opt_hitExtent, feature.getGeometry().getExtent()))) { + /** @type {Array} */ (opt_hitExtent), + feature.getGeometry().getExtent()))) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); this.drawElements_(gl, start, end, elementType, elementSize);