From 815a632be1a9ce597b95d219c109e865fe2a9145 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Mon, 18 Jul 2011 10:15:00 -0400 Subject: [PATCH] ripping out an optimization that's hurting the code readability --- world/kernel.js | 5 ++-- world/private/raw-jsworld.js | 56 +++++++++++++++++------------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/world/kernel.js b/world/kernel.js index 773d3e9..d3bb875 100644 --- a/world/kernel.js +++ b/world/kernel.js @@ -158,7 +158,6 @@ OnTick.prototype = plt.baselib.heir(WorldConfigOption.prototype); OnTick.prototype.toRawHandler = function(MACHINE) { var worldFunction = function(world, k) { - console.log('about to call the on-tick'); k(world + 1); // plt.baselib.functions.internalCallDuringPause( // MACHINE, @@ -183,7 +182,7 @@ OnTick.prototype.toRawHandler = function(MACHINE) { // // OnDraw var OnDraw = function(handler) { - WorldConfigOption.call(this, 'on-tick'); + WorldConfigOption.call(this, 'on-draw'); this.handler = handler; }; @@ -204,7 +203,7 @@ var isOnDraw = plt.baselib.makeClassPredicate(OnDraw); var DefaultOnDraw = function(toplevelNode) { - WorldConfigOption.call(this, 'on-tick'); + WorldConfigOption.call(this, 'on-draw'); this.toplevelNode = toplevelNode; }; diff --git a/world/private/raw-jsworld.js b/world/private/raw-jsworld.js index 019cfb6..653de2f 100644 --- a/world/private/raw-jsworld.js +++ b/world/private/raw-jsworld.js @@ -668,39 +668,35 @@ var rawJsworld = {}; } */ - // We try to avoid updating the dom if the value - // hasn't changed. - redraw_func(oldWorld, - function(oldRedraw) { - redraw_func(world, - function(newRedraw) { - redraw_css_func(oldWorld, - function(oldRedrawCss) { - redraw_css_func(world, - function(newRedrawCss) { - var t = sexp2tree(newRedraw); - var ns = nodes(t); - // Try to save the current selection and preserve it across - // dom updates. + redraw_func( + world, + function(newRedraw) { - if(oldRedraw !== newRedraw) { - // Kludge: update the CSS styles first. - // This is a workaround an issue with excanvas: any style change - // clears the content of the canvas, so we do this first before - // attaching the dom element. - update_css(ns, sexp2css(newRedrawCss)); - update_dom(toplevelNode, ns, relations(t)); - } else { - if (oldRedrawCss !== newRedrawCss) { - update_css(ns, sexp2css(newRedrawCss)); - } - } - k2(); - }) - }) + redraw_css_func( + world, + function(newRedrawCss) { + var t = sexp2tree(newRedraw); + var ns = nodes(t); + + // Try to save the current selection and preserve it across + // dom updates. + + // Kludge: update the CSS styles first. + // This is a workaround an issue with excanvas: any style change + // clears the content of the canvas, so we do this first before + // attaching the dom element. + update_css(ns, sexp2css(newRedrawCss)); + update_dom(toplevelNode, ns, relations(t)); + + k2(); }) - }); + }) + + + + + }, k); } }