Skip to content

Commit

Permalink
Again even less overhead in overload translation, no manual optimizat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
bjornharrtell committed Feb 12, 2016
1 parent 596a01f commit 8627a0a
Show file tree
Hide file tree
Showing 60 changed files with 621 additions and 1,035 deletions.
14 changes: 5 additions & 9 deletions src/org/locationtech/jts/algorithm/ConvexHull.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ export default class ConvexHull {
this.inputPts = null;
const overloaded = (...args) => {
if (args.length === 1) {
return ((...args) => {
let [geometry] = args;
overloaded.call(this, ConvexHull.extractCoordinates(geometry), geometry.getFactory());
})(...args);
let [geometry] = args;
overloaded.call(this, ConvexHull.extractCoordinates(geometry), geometry.getFactory());
} else if (args.length === 2) {
return ((...args) => {
let [pts, geomFactory] = args;
this.inputPts = UniqueCoordinateArrayFilter.filterCoordinates(pts);
this.geomFactory = geomFactory;
})(...args);
let [pts, geomFactory] = args;
this.inputPts = UniqueCoordinateArrayFilter.filterCoordinates(pts);
this.geomFactory = geomFactory;
}
};
return overloaded.apply(this, args);
Expand Down
82 changes: 34 additions & 48 deletions src/org/locationtech/jts/algorithm/HCoordinate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,48 @@ export default class HCoordinate {
this.w = null;
const overloaded = (...args) => {
if (args.length === 0) {
return ((...args) => {
let [] = args;
this.x = 0.0;
this.y = 0.0;
this.w = 1.0;
})(...args);
let [] = args;
this.x = 0.0;
this.y = 0.0;
this.w = 1.0;
} else if (args.length === 1) {
return ((...args) => {
let [p] = args;
this.x = p.x;
this.y = p.y;
this.w = 1.0;
})(...args);
let [p] = args;
this.x = p.x;
this.y = p.y;
this.w = 1.0;
} else if (args.length === 2) {
if (typeof args[0] === "number" && typeof args[1] === "number") {
return ((...args) => {
let [_x, _y] = args;
this.x = _x;
this.y = _y;
this.w = 1.0;
})(...args);
let [_x, _y] = args;
this.x = _x;
this.y = _y;
this.w = 1.0;
} else if (args[0] instanceof HCoordinate && args[1] instanceof HCoordinate) {
return ((...args) => {
let [p1, p2] = args;
this.x = p1.y * p2.w - p2.y * p1.w;
this.y = p2.x * p1.w - p1.x * p2.w;
this.w = p1.x * p2.y - p2.x * p1.y;
})(...args);
let [p1, p2] = args;
this.x = p1.y * p2.w - p2.y * p1.w;
this.y = p2.x * p1.w - p1.x * p2.w;
this.w = p1.x * p2.y - p2.x * p1.y;
} else if (args[0] instanceof Coordinate && args[1] instanceof Coordinate) {
return ((...args) => {
let [p1, p2] = args;
this.x = p1.y - p2.y;
this.y = p2.x - p1.x;
this.w = p1.x * p2.y - p2.x * p1.y;
})(...args);
let [p1, p2] = args;
this.x = p1.y - p2.y;
this.y = p2.x - p1.x;
this.w = p1.x * p2.y - p2.x * p1.y;
}
} else if (args.length === 3) {
return ((...args) => {
let [_x, _y, _w] = args;
this.x = _x;
this.y = _y;
this.w = _w;
})(...args);
let [_x, _y, _w] = args;
this.x = _x;
this.y = _y;
this.w = _w;
} else if (args.length === 4) {
return ((...args) => {
let [p1, p2, q1, q2] = args;
var px = p1.y - p2.y;
var py = p2.x - p1.x;
var pw = p1.x * p2.y - p2.x * p1.y;
var qx = q1.y - q2.y;
var qy = q2.x - q1.x;
var qw = q1.x * q2.y - q2.x * q1.y;
this.x = py * qw - qy * pw;
this.y = qx * pw - px * qw;
this.w = px * qy - qx * py;
})(...args);
let [p1, p2, q1, q2] = args;
var px = p1.y - p2.y;
var py = p2.x - p1.x;
var pw = p1.x * p2.y - p2.x * p1.y;
var qx = q1.y - q2.y;
var qy = q2.x - q1.x;
var qw = q1.x * q2.y - q2.x * q1.y;
this.x = py * qw - qy * pw;
this.y = qx * pw - px * qw;
this.w = px * qy - qx * py;
}
};
return overloaded.apply(this, args);
Expand Down
14 changes: 5 additions & 9 deletions src/org/locationtech/jts/algorithm/MinimumDiameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ export default class MinimumDiameter {
this.minWidth = 0.0;
const overloaded = (...args) => {
if (args.length === 1) {
return ((...args) => {
let [inputGeom] = args;
overloaded.call(this, inputGeom, false);
})(...args);
let [inputGeom] = args;
overloaded.call(this, inputGeom, false);
} else if (args.length === 2) {
return ((...args) => {
let [inputGeom, isConvex] = args;
this.inputGeom = inputGeom;
this.isConvex = isConvex;
})(...args);
let [inputGeom, isConvex] = args;
this.inputGeom = inputGeom;
this.isConvex = isConvex;
}
};
return overloaded.apply(this, args);
Expand Down
12 changes: 4 additions & 8 deletions src/org/locationtech/jts/algorithm/PointLocator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ export default class PointLocator {
this.numBoundaries = null;
const overloaded = (...args) => {
if (args.length === 0) {
return ((...args) => {
let [] = args;
})(...args);
let [] = args;
} else if (args.length === 1) {
return ((...args) => {
let [boundaryRule] = args;
if (boundaryRule === null) throw new IllegalArgumentException("Rule must be non-null");
this.boundaryRule = boundaryRule;
})(...args);
let [boundaryRule] = args;
if (boundaryRule === null) throw new IllegalArgumentException("Rule must be non-null");
this.boundaryRule = boundaryRule;
}
};
return overloaded.apply(this, args);
Expand Down
42 changes: 15 additions & 27 deletions src/org/locationtech/jts/geom/Coordinate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,19 @@ export default class Coordinate {
this.z = null;
const overloaded = (...args) => {
if (args.length === 0) {
return ((...args) => {
let [] = args;
overloaded.call(this, 0.0, 0.0);
})(...args);
let [] = args;
overloaded.call(this, 0.0, 0.0);
} else if (args.length === 1) {
return ((...args) => {
let [c] = args;
overloaded.call(this, c.x, c.y, c.z);
})(...args);
let [c] = args;
overloaded.call(this, c.x, c.y, c.z);
} else if (args.length === 2) {
return ((...args) => {
let [x, y] = args;
overloaded.call(this, x, y, Coordinate.NULL_ORDINATE);
})(...args);
let [x, y] = args;
overloaded.call(this, x, y, Coordinate.NULL_ORDINATE);
} else if (args.length === 3) {
return ((...args) => {
let [x, y, z] = args;
this.x = x;
this.y = y;
this.z = z;
})(...args);
let [x, y, z] = args;
this.x = x;
this.y = y;
this.z = z;
}
};
return overloaded.apply(this, args);
Expand Down Expand Up @@ -166,16 +158,12 @@ class DimensionalComparator {
this.dimensionsToTest = 2;
const overloaded = (...args) => {
if (args.length === 0) {
return ((...args) => {
let [] = args;
overloaded.call(this, 2);
})(...args);
let [] = args;
overloaded.call(this, 2);
} else if (args.length === 1) {
return ((...args) => {
let [dimensionsToTest] = args;
if (dimensionsToTest !== 2 && dimensionsToTest !== 3) throw new IllegalArgumentException("only 2 or 3 dimensions may be specified");
this.dimensionsToTest = dimensionsToTest;
})(...args);
let [dimensionsToTest] = args;
if (dimensionsToTest !== 2 && dimensionsToTest !== 3) throw new IllegalArgumentException("only 2 or 3 dimensions may be specified");
this.dimensionsToTest = dimensionsToTest;
}
};
return overloaded.apply(this, args);
Expand Down
12 changes: 4 additions & 8 deletions src/org/locationtech/jts/geom/CoordinateSequenceComparator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ export default class CoordinateSequenceComparator {
this.dimensionLimit = null;
const overloaded = (...args) => {
if (args.length === 0) {
return ((...args) => {
let [] = args;
this.dimensionLimit = Integer.MAX_VALUE;
})(...args);
let [] = args;
this.dimensionLimit = Integer.MAX_VALUE;
} else if (args.length === 1) {
return ((...args) => {
let [dimensionLimit] = args;
this.dimensionLimit = dimensionLimit;
})(...args);
let [dimensionLimit] = args;
this.dimensionLimit = dimensionLimit;
}
};
return overloaded.apply(this, args);
Expand Down
30 changes: 10 additions & 20 deletions src/org/locationtech/jts/geom/Envelope.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,22 @@ export default class Envelope {
this.maxy = null;
const overloaded = (...args) => {
if (args.length === 0) {
return ((...args) => {
let [] = args;
this.init();
})(...args);
let [] = args;
this.init();
} else if (args.length === 1) {
if (args[0] instanceof Coordinate) {
return ((...args) => {
let [p] = args;
this.init(p.x, p.x, p.y, p.y);
})(...args);
let [p] = args;
this.init(p.x, p.x, p.y, p.y);
} else if (args[0] instanceof Envelope) {
return ((...args) => {
let [env] = args;
this.init(env);
})(...args);
let [env] = args;
this.init(env);
}
} else if (args.length === 2) {
return ((...args) => {
let [p1, p2] = args;
this.init(p1.x, p2.x, p1.y, p2.y);
})(...args);
let [p1, p2] = args;
this.init(p1.x, p2.x, p1.y, p2.y);
} else if (args.length === 4) {
return ((...args) => {
let [x1, x2, y1, y2] = args;
this.init(x1, x2, y1, y2);
})(...args);
let [x1, x2, y1, y2] = args;
this.init(x1, x2, y1, y2);
}
};
return overloaded.apply(this, args);
Expand Down
Loading

0 comments on commit 8627a0a

Please sign in to comment.