diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-02-21 21:30:57 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-02-21 21:30:57 -0800 |
commit | 70def3209b7fb0e07c14edf514f04287c11169b6 (patch) | |
tree | 8a4cb0633ebe81a2bc07663748ac38110cbd9098 /baremetal | |
parent | 61c47f6db690b4e2ab0045b44db8017d59334488 (diff) | |
download | mu-70def3209b7fb0e07c14edf514f04287c11169b6.tar.gz |
7774
YAGNI over premature optimization. Avoid unnecessary copies.
Diffstat (limited to 'baremetal')
-rw-r--r-- | baremetal/shell/main.mu | 7 | ||||
-rw-r--r-- | baremetal/shell/sandbox.mu | 8 |
2 files changed, 7 insertions, 8 deletions
diff --git a/baremetal/shell/main.mu b/baremetal/shell/main.mu index 436d6104..71f73e30 100644 --- a/baremetal/shell/main.mu +++ b/baremetal/shell/main.mu @@ -18,18 +18,19 @@ fn main { } } -fn run in: (addr stream byte), out: (addr stream byte) { +fn run in: (addr gap-buffer), out: (addr stream byte) { # tokenize # insert parens # transform infix # token tree # syntax tree + rewind-gap-buffer in clear-stream out { - var done?/eax: boolean <- stream-empty? in + var done?/eax: boolean <- gap-buffer-scan-done? in compare done?, 0/false break-if-!= - var g/eax: grapheme <- read-grapheme in + var g/eax: grapheme <- read-from-gap-buffer in write-grapheme out, g loop } diff --git a/baremetal/shell/sandbox.mu b/baremetal/shell/sandbox.mu index 3b489fdd..f6d0c6cb 100644 --- a/baremetal/shell/sandbox.mu +++ b/baremetal/shell/sandbox.mu @@ -80,14 +80,12 @@ fn edit-sandbox _self: (addr sandbox), key: byte { compare g, 0x13/ctrl-s break-if-!= # ctrl-s: run sandbox(es) - var buffer-storage: (stream byte 0x1000) - var buffer/edi: (addr stream byte) <- address buffer-storage var data-ah/eax: (addr handle gap-buffer) <- get self, data - var data/eax: (addr gap-buffer) <- lookup *data-ah - emit-gap-buffer data, buffer + var _data/eax: (addr gap-buffer) <- lookup *data-ah + var data/ecx: (addr gap-buffer) <- copy _data var value-ah/eax: (addr handle stream byte) <- get self, value var value/eax: (addr stream byte) <- lookup *value-ah - run buffer, value + run data, value return } add-grapheme-to-sandbox self, g |