ripping out an optimization that's hurting the code readability

This commit is contained in:
Danny Yoo 2011-07-18 10:15:00 -04:00
parent 1ba498b4e3
commit 815a632be1
2 changed files with 28 additions and 33 deletions

View File

@ -158,7 +158,6 @@ OnTick.prototype = plt.baselib.heir(WorldConfigOption.prototype);
OnTick.prototype.toRawHandler = function(MACHINE) { OnTick.prototype.toRawHandler = function(MACHINE) {
var worldFunction = function(world, k) { var worldFunction = function(world, k) {
console.log('about to call the on-tick');
k(world + 1); k(world + 1);
// plt.baselib.functions.internalCallDuringPause( // plt.baselib.functions.internalCallDuringPause(
// MACHINE, // MACHINE,
@ -183,7 +182,7 @@ OnTick.prototype.toRawHandler = function(MACHINE) {
// // OnDraw // // OnDraw
var OnDraw = function(handler) { var OnDraw = function(handler) {
WorldConfigOption.call(this, 'on-tick'); WorldConfigOption.call(this, 'on-draw');
this.handler = handler; this.handler = handler;
}; };
@ -204,7 +203,7 @@ var isOnDraw = plt.baselib.makeClassPredicate(OnDraw);
var DefaultOnDraw = function(toplevelNode) { var DefaultOnDraw = function(toplevelNode) {
WorldConfigOption.call(this, 'on-tick'); WorldConfigOption.call(this, 'on-draw');
this.toplevelNode = toplevelNode; this.toplevelNode = toplevelNode;
}; };

View File

@ -668,15 +668,13 @@ var rawJsworld = {};
} }
*/ */
// We try to avoid updating the dom if the value
// hasn't changed. redraw_func(
redraw_func(oldWorld, world,
function(oldRedraw) {
redraw_func(world,
function(newRedraw) { function(newRedraw) {
redraw_css_func(oldWorld,
function(oldRedrawCss) { redraw_css_func(
redraw_css_func(world, world,
function(newRedrawCss) { function(newRedrawCss) {
var t = sexp2tree(newRedraw); var t = sexp2tree(newRedraw);
var ns = nodes(t); var ns = nodes(t);
@ -684,23 +682,21 @@ var rawJsworld = {};
// Try to save the current selection and preserve it across // Try to save the current selection and preserve it across
// dom updates. // dom updates.
if(oldRedraw !== newRedraw) {
// Kludge: update the CSS styles first. // Kludge: update the CSS styles first.
// This is a workaround an issue with excanvas: any style change // This is a workaround an issue with excanvas: any style change
// clears the content of the canvas, so we do this first before // clears the content of the canvas, so we do this first before
// attaching the dom element. // attaching the dom element.
update_css(ns, sexp2css(newRedrawCss)); update_css(ns, sexp2css(newRedrawCss));
update_dom(toplevelNode, ns, relations(t)); update_dom(toplevelNode, ns, relations(t));
} else {
if (oldRedrawCss !== newRedrawCss) {
update_css(ns, sexp2css(newRedrawCss));
}
}
k2(); k2();
}) })
}) })
})
});
}, k); }, k);
} }
} }