Avoid use of goog.array.clone with arrays

This commit is contained in:
Tim Schaub
2015-01-15 12:39:36 -07:00
parent c23ae78978
commit 06dc0902c6
5 changed files with 7 additions and 8 deletions

View File

@@ -78,7 +78,7 @@ ol.FeatureOverlay = function(opt_options) {
if (goog.isDef(options.features)) { if (goog.isDef(options.features)) {
if (goog.isArray(options.features)) { if (goog.isArray(options.features)) {
this.setFeatures(new ol.Collection(goog.array.clone(options.features))); this.setFeatures(new ol.Collection(options.features.slice()));
} else { } else {
goog.asserts.assertInstanceof(options.features, ol.Collection); goog.asserts.assertInstanceof(options.features, ol.Collection);
this.setFeatures(options.features); this.setFeatures(options.features);

View File

@@ -1,6 +1,5 @@
goog.provide('ol.format.Feature'); goog.provide('ol.format.Feature');
goog.require('goog.array');
goog.require('ol.geom.Geometry'); goog.require('ol.geom.Geometry');
goog.require('ol.proj'); goog.require('ol.proj');
@@ -177,7 +176,7 @@ ol.format.Feature.transformWithOptions = function(
// FIXME this is necessary because ol.format.GML treats extents // FIXME this is necessary because ol.format.GML treats extents
// as geometries // as geometries
return ol.proj.transformExtent( return ol.proj.transformExtent(
write ? goog.array.clone(geometry) : geometry, write ? geometry.slice() : geometry,
write ? featureProjection : dataProjection, write ? featureProjection : dataProjection,
write ? dataProjection : featureProjection); write ? dataProjection : featureProjection);
} }

View File

@@ -58,7 +58,7 @@ ol.layer.Group = function(opt_options) {
if (goog.isDefAndNotNull(layers)) { if (goog.isDefAndNotNull(layers)) {
if (goog.isArray(layers)) { if (goog.isArray(layers)) {
layers = new ol.Collection(goog.array.clone(layers)); layers = new ol.Collection(layers.slice());
} else { } else {
goog.asserts.assertInstanceof(layers, ol.Collection); goog.asserts.assertInstanceof(layers, ol.Collection);
layers = layers; layers = layers;

View File

@@ -1500,7 +1500,7 @@ ol.Map.createOptionsInternal = function(options) {
var controls; var controls;
if (goog.isDef(options.controls)) { if (goog.isDef(options.controls)) {
if (goog.isArray(options.controls)) { if (goog.isArray(options.controls)) {
controls = new ol.Collection(goog.array.clone(options.controls)); controls = new ol.Collection(options.controls.slice());
} else { } else {
goog.asserts.assertInstanceof(options.controls, ol.Collection); goog.asserts.assertInstanceof(options.controls, ol.Collection);
controls = options.controls; controls = options.controls;
@@ -1512,7 +1512,7 @@ ol.Map.createOptionsInternal = function(options) {
var interactions; var interactions;
if (goog.isDef(options.interactions)) { if (goog.isDef(options.interactions)) {
if (goog.isArray(options.interactions)) { if (goog.isArray(options.interactions)) {
interactions = new ol.Collection(goog.array.clone(options.interactions)); interactions = new ol.Collection(options.interactions.slice());
} else { } else {
goog.asserts.assertInstanceof(options.interactions, ol.Collection); goog.asserts.assertInstanceof(options.interactions, ol.Collection);
interactions = options.interactions; interactions = options.interactions;
@@ -1524,7 +1524,7 @@ ol.Map.createOptionsInternal = function(options) {
var overlays; var overlays;
if (goog.isDef(options.overlays)) { if (goog.isDef(options.overlays)) {
if (goog.isArray(options.overlays)) { if (goog.isArray(options.overlays)) {
overlays = new ol.Collection(goog.array.clone(options.overlays)); overlays = new ol.Collection(options.overlays.slice());
} else { } else {
goog.asserts.assertInstanceof(options.overlays, ol.Collection); goog.asserts.assertInstanceof(options.overlays, ol.Collection);
overlays = options.overlays; overlays = options.overlays;

View File

@@ -260,7 +260,7 @@ goog.exportProperty(
* @return {Array.<number>} Hint. * @return {Array.<number>} Hint.
*/ */
ol.View.prototype.getHints = function() { ol.View.prototype.getHints = function() {
return goog.array.clone(this.hints_); return this.hints_.slice();
}; };