Permalink
Browse files

Removing the typed arrays

Its not clear that we will be able to leverage the Float64Array.  It may also be that the overhead of constructing these small arrays negates any benefit of faster access.  And for all coordinate arrays, we'll need arrays that grow/shrink.
  • Loading branch information...
1 parent 176f18c commit 8f578b88b18a072e06f3ef731ba8c6bc5228f305 @tschaub tschaub committed Feb 20, 2013
@@ -24,12 +24,16 @@ ol.geom.LineString = function(coordinates) {
length = count * dimension;
/**
- * @type {Float64Array}
+ * @type {Array}
*/
- this.coordinates = new Float64Array(length);
- for (var i = 0; i < count; ++i) {
+ this.coordinates = new Array(length);
+ var i, offset, j;
+ for (i = 0; i < count; ++i) {
goog.asserts.assert(coordinates[i].length === dimension);
- this.coordinates.set(coordinates[i], i * dimension);
+ offset = i * dimension;
+ for (j = 0; j < dimension; ++j) {
+ this.coordinates[offset + j] = coordinates[i][j];
+ }
}
/**
@@ -18,9 +18,9 @@ ol.geom.Point = function(coordinates) {
goog.base(this);
/**
- * @type {Float64Array}
+ * @type {Array}
*/
- this.coordinates = new Float64Array(coordinates);
+ this.coordinates = coordinates;
/**
* @type {number}
@@ -1,3 +1,5 @@
+goog.provide('ol.test.geom.LinearRing');
+
describe('ol.geom.LinearRing', function() {
describe('constructor', function() {
@@ -17,9 +19,8 @@ describe('ol.geom.LinearRing', function() {
describe('#coordinates', function() {
- it('is a Float64Array', function() {
+ it('is an array', function() {
var ring = new ol.geom.LinearRing([[10, 20], [30, 40]]);
- expect(ring.coordinates).toBeA(Float64Array);
expect(ring.coordinates.length).toBe(4);
expect(ring.coordinates[0]).toBe(10);
@@ -47,3 +48,4 @@ describe('ol.geom.LinearRing', function() {
});
+goog.require('ol.geom.LinearRing');
@@ -20,9 +20,8 @@ describe('ol.geom.LineString', function() {
describe('#coordinates', function() {
- it('is a Float64Array', function() {
+ it('is an array', function() {
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
- expect(line.coordinates).toBeA(Float64Array);
expect(line.coordinates.length).toBe(4);
expect(line.coordinates[0]).toBe(10);
@@ -20,9 +20,8 @@ describe('ol.geom.Point', function() {
describe('#coordinates', function() {
- it('is a Float64Array', function() {
+ it('is an array', function() {
var point = new ol.geom.Point([10, 20]);
- expect(point.coordinates).toBeA(Float64Array);
expect(point.coordinates.length).toBe(2);
expect(point.coordinates[0]).toBe(10);

0 comments on commit 8f578b8

Please sign in to comment.