Caching array length instead of accessing it with each iteration. r=crschmidt (closes #1636)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7627 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-07-31 04:44:25 +00:00
parent 89b10da8db
commit 66a4c6fb0e
50 changed files with 196 additions and 196 deletions

View File

@@ -116,7 +116,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
* y - {Float} The y-displacement (in map units)
*/
move: function(x, y) {
for(var i = 0; i < this.components.length - 1; i++) {
for(var i = 0, len=this.components.length; i<len - 1; i++) {
this.components[i].move(x, y);
}
},
@@ -131,7 +131,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
* origin - {<OpenLayers.Geometry.Point>} Center point for the rotation
*/
rotate: function(angle, origin) {
for(var i=0; i<this.components.length - 1; ++i) {
for(var i=0, len=this.components.length; i<len - 1; ++i) {
this.components[i].rotate(angle, origin);
}
},
@@ -150,7 +150,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
* ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.
*/
resize: function(scale, origin, ratio) {
for(var i=0; i<this.components.length - 1; ++i) {
for(var i=0, len=this.components.length; i<len - 1; ++i) {
this.components[i].resize(scale, origin, ratio);
}
},
@@ -168,7 +168,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
*/
transform: function(source, dest) {
if (source && dest) {
for (var i = 0; i < this.components.length - 1; i++) {
for (var i=0, len=this.components.length; i<len - 1; i++) {
var component = this.components[i];
component.transform(source, dest);
}
@@ -188,7 +188,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
var area = 0.0;
if ( this.components && (this.components.length > 2)) {
var sum = 0.0;
for (var i = 0; i < this.components.length - 1; i++) {
for (var i=0, len=this.components.length; i<len - 1; i++) {
var b = this.components[i];
var c = this.components[i+1];
sum += (b.x + c.x) * (c.y - b.y);
@@ -309,7 +309,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
);
} else {
// check for component intersections
for(var i=0; i<geometry.components.length; ++ i) {
for(var i=0, len=geometry.components.length; i<len; ++ i) {
intersect = geometry.components[i].intersects(this);
if(intersect) {
break;