about summary refs log tree commit diff stats
path: root/sandbox/009-sandbox-test.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-06-25 10:49:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-06-25 11:02:15 -0700
commitdc5f112c3ea8aff1a389513fa6c33d88fab07420 (patch)
tree5e887029c973d8a5b292fd9993c5ad81cf8c4c61 /sandbox/009-sandbox-test.mu
parentd2f0704962eb0e43f3db8b461dd6d48ee9297f73 (diff)
downloadmu-dc5f112c3ea8aff1a389513fa6c33d88fab07420.tar.gz
3958
Improvement on fix 3957: rather than put a band-aid over a slow
operation, eliminate the slowdown entirely.

In this case it turns out we're unnecessarily saving files to disk when
they could never be modified. Are we doing this on F4 as well?!
Diffstat (limited to 'sandbox/009-sandbox-test.mu')
-rw-r--r--sandbox/009-sandbox-test.mu18
1 files changed, 9 insertions, 9 deletions
diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu
index 7c6c0804..65381a2b 100644
--- a/sandbox/009-sandbox-test.mu
+++ b/sandbox/009-sandbox-test.mu
@@ -97,7 +97,7 @@ container sandbox [
 # include expected response when saving or restoring a sandbox
 before <end-save-sandbox> [
   {
-    expected-response:text <- get *curr, expected-response:offset
+    expected-response:text <- get *sandbox, expected-response:offset
     break-unless expected-response
     filename <- append filename, [.out]
     resources <- dump resources, filename, expected-response
@@ -128,20 +128,18 @@ after <global-touch> [
     below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins
     break-unless below-sandbox-editor?
     # identify the sandbox whose output is being clicked on
-    sandbox:&:sandbox <- find-click-in-sandbox-output env, click-row
+    sandbox:&:sandbox, sandbox-index:num <- find-click-in-sandbox-output env, click-row
     break-unless sandbox
-    screen <- update-status screen, [updating...      ], 245/grey
     # toggle its expected-response, and save session
     sandbox <- toggle-expected-response sandbox
-    save-sandboxes env, resources
+    save-sandbox resources, sandbox, sandbox-index
     screen <- render-sandbox-side screen, env, render
-    screen <- update-status screen, [                 ], 245/grey
     screen <- update-cursor screen, current-sandbox, env
     loop +next-event
   }
 ]
 
-def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox [
+def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:sandbox, sandbox-index:num [
   local-scope
   load-ingredients
   # assert click-row >= sandbox.starting-row-on-screen
@@ -150,6 +148,7 @@ def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:s
   clicked-on-sandboxes?:bool <- greater-or-equal click-row, start
   assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor]
   # while click-row < sandbox.next-sandbox.starting-row-on-screen
+  sandbox-index <- copy 0
   {
     next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
     break-unless next-sandbox
@@ -157,14 +156,15 @@ def find-click-in-sandbox-output env:&:environment, click-row:num -> sandbox:&:s
     found?:bool <- lesser-than click-row, next-start
     break-if found?
     sandbox <- copy next-sandbox
+    sandbox-index <- add sandbox-index, 1
     loop
   }
   # return sandbox if click is in its output region
   response-starting-row:num <- get *sandbox, response-starting-row-on-screen:offset
-  return-unless response-starting-row, 0/no-click-in-sandbox-output
+  return-unless response-starting-row, 0/no-click-in-sandbox-output, 0/sandbox-index
   click-in-response?:bool <- greater-or-equal click-row, response-starting-row
-  return-unless click-in-response?, 0/no-click-in-sandbox-output
-  return sandbox
+  return-unless click-in-response?, 0/no-click-in-sandbox-output, 0/sandbox-index
+  return sandbox, sandbox-index
 ]
 
 def toggle-expected-response sandbox:&:sandbox -> sandbox:&:sandbox [