Skip to content

Commit

Permalink
Turn off the compiler's "advanced" optimizations.
Browse files Browse the repository at this point in the history
The renaming of attributes is totally not worth the hassle of maintaining an
externs file (or using the awkward `foo["bar"]` syntax). The file size
reduction from the advanced optimizations was negligible, besides!
  • Loading branch information
mbostock committed Jan 5, 2011
1 parent bfed47b commit bdcb648
Show file tree
Hide file tree
Showing 33 changed files with 739 additions and 913 deletions.
30 changes: 20 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ JS_COMPILER = \
java -jar lib/google-compiler/compiler.jar \
--externs=src/externs.js \
--warning_level=VERBOSE \
--compilation_level=ADVANCED_OPTIMIZATIONS \
--charset=UTF-8 \
--output_wrapper='(function(){%output%})()'
--charset=UTF-8

all: \
d3.js \
Expand All @@ -21,9 +19,11 @@ all: \
d3.time.min.js

.INTERMEDIATE d3.js: \
src/start.js \
d3.core.js \
d3.scale.js \
d3.svg.js
d3.svg.js \
src/end.js

d3.core.js: \
src/core/core.js \
Expand Down Expand Up @@ -76,32 +76,42 @@ d3.svg.js: \
src/svg/mouse.js

d3.layout.js: \
src/start.js \
src/layout/layout.js \
src/layout/chord.js
src/layout/chord.js \
src/end.js

d3.geo.js: \
src/start.js \
src/geo/geo.js \
src/geo/albers.js \
src/geo/mercator.js \
src/geo/path.js
src/geo/path.js \
src/end.js

d3.csv.js: \
src/start.js \
src/csv/csv.js \
src/csv/parse.js \
src/csv/format.js
src/csv/format.js \
src/end.js

d3.time.js: \
src/start.js \
src/time/time.js \
src/time/format.js
src/time/format.js \
src/end.js

d3.geom.js: \
src/start.js \
src/geom/geom.js \
src/geom/hull.js \
src/geom/polygon.js \
src/geom/voronoi.js \
src/geom/delaunay.js
src/geom/delaunay.js \
src/end.js

%.min.js: %.js Makefile src/externs.js
%.min.js: %.js Makefile
@rm -f $@
$(JS_COMPILER) --js $< --js_output_file $@

Expand Down
3 changes: 2 additions & 1 deletion d3.csv.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
d3.csv = function(url, callback) {
(function(){d3.csv = function(url, callback) {
d3.text(url, "text/csv", function(text) {
callback(text && d3.csv.parse(text));
});
Expand Down Expand Up @@ -81,3 +81,4 @@ function d3_csv_formatValue(text) {
? "\"" + text.replace(/\"/g, "\"\"") + "\""
: text;
}
})()
5 changes: 2 additions & 3 deletions d3.csv.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion d3.geo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
d3.geo = {};
(function(){d3.geo = {};
// Derived from Tom Carden's Albers implementation for Protovis.
// http://gist.github.com/476238
// http://mathworld.wolfram.com/AlbersEqual-AreaConicProjection.html
Expand Down Expand Up @@ -361,3 +361,4 @@ function d3_path_circle(radius) {
function d3_geo_pathZero() {
return 0;
}
})()
18 changes: 8 additions & 10 deletions d3.geo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 27 additions & 26 deletions d3.geom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
d3.geom = {};
(function(){d3.geom = {};
/**
* Computes the 2D convex hull of a set of points using Graham's scanning
* algorithm. The algorithm has been implemented as described in Cormen,
Expand Down Expand Up @@ -186,11 +186,11 @@ d3.geom.voronoi = function(vertices) {
y1,
y2;
if (e.a == 1 && e.b >= 0) {
s1 = e.ep["r"];
s2 = e.ep["l"];
s1 = e.ep.r;
s2 = e.ep.l;
} else {
s1 = e.ep["l"];
s2 = e.ep["r"];
s1 = e.ep.l;
s2 = e.ep.r;
}
if (e.a == 1) {
y1 = s1 ? s1.y : -1e6;
Expand All @@ -205,8 +205,8 @@ d3.geom.voronoi = function(vertices) {
}
var v1 = [x1, y1],
v2 = [x2, y2];
polygons[e.region["l"].index].push(v1, v2);
polygons[e.region["r"].index].push(v1, v2);
polygons[e.region.l.index].push(v1, v2);
polygons[e.region.r.index].push(v1, v2);
});

// Reconnect the polygon segments into counterclockwise loops.
Expand Down Expand Up @@ -255,8 +255,8 @@ function d3_voronoi_tessellate(vertices, callback) {
init: function() {
EdgeList.leftEnd = EdgeList.createHalfEdge(null, "l");
EdgeList.rightEnd = EdgeList.createHalfEdge(null, "l");
EdgeList.leftEnd["r"] = EdgeList.rightEnd;
EdgeList.rightEnd["l"] = EdgeList.leftEnd;
EdgeList.leftEnd.r = EdgeList.rightEnd;
EdgeList.rightEnd.l = EdgeList.leftEnd;
EdgeList.list.unshift(EdgeList.leftEnd, EdgeList.rightEnd);
},

Expand All @@ -271,33 +271,33 @@ function d3_voronoi_tessellate(vertices, callback) {
},

insert: function(lb, he) {
he["l"] = lb;
he["r"] = lb["r"];
lb["r"]["l"] = he;
lb["r"] = he;
he.l = lb;
he.r = lb.r;
lb.r.l = he;
lb.r = he;
},

leftBound: function(p) {
var he = EdgeList.leftEnd;
do {
he = he["r"];
he = he.r;
} while (he != EdgeList.rightEnd && Geom.rightOf(he, p));
he = he["l"];
he = he.l;
return he;
},

del: function(he) {
he["l"]["r"] = he["r"];
he["r"]["l"] = he["l"];
he.l.r = he.r;
he.r.l = he.l;
he.edge = null;
},

right: function(he) {
return he["r"];
return he.r;
},

left: function(he) {
return he["l"];
return he.l;
},

leftRegion: function(he) {
Expand Down Expand Up @@ -345,7 +345,7 @@ function d3_voronoi_tessellate(vertices, callback) {
intersect: function(el1, el2) {
var e1 = el1.edge,
e2 = el2.edge;
if (!e1 || !e2 || (e1.region["r"] == e2.region["r"])) {
if (!e1 || !e2 || (e1.region.r == e2.region.r)) {
return null;
}
var d = (e1.a * e2.b) - (e1.b * e2.a);
Expand All @@ -354,8 +354,8 @@ function d3_voronoi_tessellate(vertices, callback) {
}
var xint = (e1.c * e2.b - e2.c * e1.b) / d,
yint = (e2.c * e1.a - e1.c * e2.a) / d,
e1r = e1.region["r"],
e2r = e2.region["r"],
e1r = e1.region.r,
e2r = e2.region.r,
el,
e;
if ((e1r.y < e2r.y) ||
Expand All @@ -366,7 +366,7 @@ function d3_voronoi_tessellate(vertices, callback) {
el = el2;
e = e2;
}
var rightOfSite = (xint >= e.region["r"].x);
var rightOfSite = (xint >= e.region.r.x);
if ((rightOfSite && (el.side == "l")) ||
(!rightOfSite && (el.side == "r"))) {
return null;
Expand All @@ -379,7 +379,7 @@ function d3_voronoi_tessellate(vertices, callback) {

rightOf: function(he, p) {
var e = he.edge,
topsite = e.region["r"],
topsite = e.region.r,
rightOfSite = (p.x > topsite.x);

if (rightOfSite && (he.side == "l")) {
Expand Down Expand Up @@ -407,7 +407,7 @@ function d3_voronoi_tessellate(vertices, callback) {
}
}
if (!fast) {
var dxs = topsite.x - e.region["l"].x;
var dxs = topsite.x - e.region.l.x;
above = (e.b * (dxp * dxp - dyp * dyp)) <
(dxs * dyp * (1 + 2 * dxp / dxs + e.b * e.b));

Expand Down Expand Up @@ -574,7 +574,7 @@ d3.geom.delaunay = function(vertices) {

// Use the Voronoi tessellation to determine Delaunay edges.
d3_voronoi_tessellate(vertices, function(e) {
edges[e.region["l"].index].push(vertices[e.region["r"].index]);
edges[e.region.l.index].push(vertices[e.region.r.index]);
});

// Reconnect the edges into counterclockwise triangles.
Expand All @@ -595,3 +595,4 @@ d3.geom.delaunay = function(vertices) {

return triangles;
};
})()
Loading

0 comments on commit bdcb648

Please sign in to comment.