diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-14 21:37:24 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-14 21:37:24 -0700 |
commit | 5f60c00a9026eb382c064d76b50cc6ce756514fe (patch) | |
tree | 422a53c92489cdf341bc2c81336fbede597b5bfe | |
parent | 094548498bfd351d2b2f7323e7757113654dbab1 (diff) | |
download | mu-5f60c00a9026eb382c064d76b50cc6ce756514fe.tar.gz |
1783 - stable if sluggish on caleb's 512MB server
Profiling shows the bulk of time is spent in read_memory, canonize, absolutize. But I'm not sure how to optimize those places.
-rw-r--r-- | 010vm.cc | 2 | ||||
-rw-r--r-- | edit.mu | 51 |
2 files changed, 45 insertions, 8 deletions
diff --git a/010vm.cc b/010vm.cc index 27224f03..f1fb2f17 100644 --- a/010vm.cc +++ b/010vm.cc @@ -270,7 +270,5 @@ void dump_memory() { } } :(before "End Includes") -#include <map> -using std::map; #include<utility> using std::pair; diff --git a/edit.mu b/edit.mu index 518d7ed7..255e63bd 100644 --- a/edit.mu +++ b/edit.mu @@ -3,13 +3,52 @@ recipe main [ local-scope open-console - initial-recipe:address:array:character <- new [recipe new-add [ - x:number <- next-ingredient - y:number <- next-ingredient - z:number <- add x:number, y:number - reply z:number + initial-recipe:address:array:character <- new [ +# return true if a list of numbers contains the pattern 1, 5, 3 +recipe check [ + default-space:address:array:location <- new location:type, 30:literal + state:number <- copy 0:literal + { + +next-number + curr:number, found?:boolean <- next-ingredient + break-unless found?:boolean + # if curr is 1, state = 1 + { + state1:boolean <- equal curr:number, 1:literal + break-unless state1:boolean + state:number <- copy 1:literal + loop +next-number:label + } + # if state is 1 and curr is 5, state = 2 + { + state-is-1?:boolean <- equal state:number, 1:literal + break-unless state-is-1?:boolean + state2:boolean <- equal curr:number, 5:literal + break-unless state2:boolean + state:number <- copy 2:literal + loop +next-number:label + } + # if state is 2 and curr is 3, return true + { + state-is-2?:boolean <- equal state:number, 2:literal + break-unless state-is-2?:boolean + state3:boolean <- equal curr:number, 3:literal + break-unless state3:boolean + reply 1:literal/found + } + # otherwise reset state + #state:number <- copy 0:literal + loop + } + reply 0:literal/not-found ]] - initial-sandbox:address:array:character <- new [new-add 2:literal, 3:literal] +#? initial-recipe:address:array:character <- new [recipe new-add [ +#? x:number <- next-ingredient +#? y:number <- next-ingredient +#? z:number <- add x:number, y:number +#? reply z:number +#? ]] + initial-sandbox:address:array:character <- new [] env:address:programming-environment-data <- new-programming-environment 0:literal/screen, initial-recipe:address:array:character, initial-sandbox:address:array:character render-all 0:literal/address, env:address:programming-environment-data event-loop 0:literal/screen, 0:literal/console, env:address:programming-environment-data |