瀏覽代碼

Remove recursion in context rendering.

Herbert Vojčík 7 年之前
父節點
當前提交
17397905e3
共有 2 個文件被更改,包括 48 次插入27 次删除
  1. 38 19
      src/IDE.js
  2. 10 8
      src/IDE.st

+ 38 - 19
src/IDE.js

@@ -6276,47 +6276,66 @@ selector: "renderContext:on:",
 protocol: "rendering",
 fn: function (aContext,html){
 var self=this,$self=this;
-var li;
+var li,context;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$3,$receiver;
+var $1,$2;
+context=aContext;
+$recv((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv(context)._notNil();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}))._whileTrue_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
 li=$recv(html)._li();
-$1=$recv($self["@selectedContext"]).__eq(aContext);
+li;
+$1=$recv($self["@selectedContext"]).__eq(context);
 if($core.assert($1)){
 $recv(li)._class_("selected");
 }
 $2=li;
-$recv($2)._with_($recv(aContext)._asString());
-$recv($2)._onClick_((function(){
+$recv($2)._with_($recv(context)._asString());
+$recv($2)._onClick_($recv(context)._in_((function(ctx){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
+return $core.withContext(function($ctx3) {
 //>>excludeEnd("ctx");
-return $self._selectContext_(aContext);
+return (function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
+return $core.withContext(function($ctx4) {
 //>>excludeEnd("ctx");
-}));
-$3=$recv(aContext)._outerContext();
+return $self._selectContext_(ctx);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["outerContext"]=1;
+}, function($ctx4) {$ctx4.fillBlock({},$ctx3,5)});
 //>>excludeEnd("ctx");
-if(($receiver = $3) == null || $receiver.a$nil){
-$3;
-} else {
-$self._renderContext_on_($recv(aContext)._outerContext(),html);
-}
+});
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({ctx:ctx},$ctx2,4)});
+//>>excludeEnd("ctx");
+})));
+context=$recv(context)._outerContext();
+return context;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
+//>>excludeEnd("ctx");
+}));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"renderContext:on:",{aContext:aContext,html:html,li:li},$globals.Debugger)});
+}, function($ctx1) {$ctx1.fill(self,"renderContext:on:",{aContext:aContext,html:html,li:li,context:context},$globals.Debugger)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aContext", "html"],
-source: "renderContext: aContext on: html\x0a\x09| li |\x0a\x09li := html li.\x0a\x09selectedContext = aContext ifTrue: [\x0a\x09\x09li class: 'selected' ].\x0a\x09li\x0a\x09\x09with: aContext asString;\x0a\x09\x09onClick: [ self selectContext: aContext ].\x0a\x09aContext outerContext ifNotNil: [ self renderContext: aContext outerContext on: html ]",
+source: "renderContext: aContext on: html\x0a\x09| li context |\x0a\x09context := aContext.\x0a\x09\x0a\x09[ context notNil ] whileTrue: [\x0a\x09\x09li := html li.\x0a\x09\x09selectedContext = context ifTrue: [ li class: 'selected' ].\x0a\x09\x09li\x0a\x09\x09\x09with: context asString;\x0a\x09\x09\x09onClick: (context in: [:ctx | [ self selectContext: ctx ]]).\x0a\x09\x09context := context outerContext ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["li", "ifTrue:", "=", "class:", "with:", "asString", "onClick:", "selectContext:", "ifNotNil:", "outerContext", "renderContext:on:"]
+messageSends: ["whileTrue:", "notNil", "li", "ifTrue:", "=", "class:", "with:", "asString", "onClick:", "in:", "selectContext:", "outerContext"]
 }),
 $globals.Debugger);
 

+ 10 - 8
src/IDE.st

@@ -1412,14 +1412,16 @@ renderButtonsOn: html
 !
 
 renderContext: aContext on: html
-	| li |
-	li := html li.
-	selectedContext = aContext ifTrue: [
-		li class: 'selected' ].
-	li
-		with: aContext asString;
-		onClick: [ self selectContext: aContext ].
-	aContext outerContext ifNotNil: [ self renderContext: aContext outerContext on: html ]
+	| li context |
+	context := aContext.
+	
+	[ context notNil ] whileTrue: [
+		li := html li.
+		selectedContext = context ifTrue: [ li class: 'selected' ].
+		li
+			with: context asString;
+			onClick: (context in: [:ctx | [ self selectContext: ctx ]]).
+		context := context outerContext ]
 !
 
 renderTopPanelOn: html