about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-06-25 13:04:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-06-25 13:04:04 -0700
commite3c9e1536154e0dee2c15b556a2a6b9f6524e114 (patch)
tree45afca3c6b1710188a25089717d1200d3c022932 /edit
parentdc5f112c3ea8aff1a389513fa6c33d88fab07420 (diff)
downloadmu-e3c9e1536154e0dee2c15b556a2a6b9f6524e114.tar.gz
3959
Don't unnecessarily write sandboxes to disk on F4.

This seems to save almost 20% time when processing a large lesson
directory with 36 sandboxes.
Diffstat (limited to 'edit')
-rw-r--r--edit/005-sandbox.mu15
1 files changed, 13 insertions, 2 deletions
diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu
index 8fd88cba..3e609d70 100644
--- a/edit/005-sandbox.mu
+++ b/edit/005-sandbox.mu
@@ -169,13 +169,14 @@ def run-sandboxes env:&:environment, resources:&:resources, screen:&:screen -> e
     sandbox-count:num <- get *env, number-of-sandboxes:offset
     sandbox-count <- add sandbox-count, 1
     *env <- put *env, number-of-sandboxes:offset, sandbox-count
+    # save all sandboxes
+    # needs to be before running them, in case we die when running
+    save-sandboxes env, resources
     # clear sandbox editor
     init:&:duplex-list:char <- push 167/§, 0/tail
     *current-sandbox <- put *current-sandbox, data:offset, init
     *current-sandbox <- put *current-sandbox, top-of-screen:offset, init
   }
-  # save all sandboxes before running, just in case we die when running
-  save-sandboxes env, resources
   # run all sandboxes
   curr:&:sandbox <- get *env, sandbox:offset
   idx:num <- copy 0
@@ -226,6 +227,7 @@ def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [
 def save-sandboxes env:&:environment, resources:&:resources -> resources:&:resources [
   local-scope
   load-ingredients
+  trace 11, [app], [save sandboxes]
   current-sandbox:&:editor <- get *env, current-sandbox:offset
   # first clear previous versions, in case we deleted some sandbox
   $system [rm lesson/[0-9]* >/dev/null 2>/dev/null]  # some shells can't handle '>&'
@@ -608,11 +610,16 @@ scenario run-updates-results [
     .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
     .                                                  ┊                                                 .
   ]
+  # the new sandbox should be saved to disk
+  trace-should-contain [
+    app: save sandboxes
+  ]
   # no need to update editor
   trace-should-not-contain [
     app: render recipes
   ]
   # make a change (incrementing one of the args to 'add'), then rerun
+  $clear-trace
   assume-console [
     left-click 4, 28  # one past the value of the second arg
     press backspace
@@ -635,6 +642,10 @@ scenario run-updates-results [
     .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
     .                                                  ┊                                                 .
   ]
+  # no need to save sandboxes all over again
+  trace-should-not-contain [
+    app: save sandboxes
+  ]
 ]
 
 scenario run-instruction-manages-screen-per-sandbox [