about summary refs log tree commit diff stats
path: root/061text.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-09-23 18:31:26 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-09-23 18:41:47 -0700
commit72cf994869e19f6bdc4678e1122f0082d07d4a11 (patch)
treee7a39da677884476a3088a96b1dab125d310316d /061text.mu
parent50685c29bdafaa3fab19c832b421707b0442fdc6 (diff)
downloadmu-72cf994869e19f6bdc4678e1122f0082d07d4a11.tar.gz
4002
Diffstat (limited to '061text.mu')
-rw-r--r--061text.mu41
1 files changed, 13 insertions, 28 deletions
diff --git a/061text.mu b/061text.mu
index 913bc53a..1ef8c393 100644
--- a/061text.mu
+++ b/061text.mu
@@ -11,12 +11,9 @@ def equal a:text, b:text -> result:bool [
   a-len:num <- length *a
   b-len:num <- length *b
   # compare lengths
-  {
-    trace 99, [text-equal], [comparing lengths]
-    length-equal?:bool <- equal a-len, b-len
-    break-if length-equal?
-    return 0
-  }
+  trace 99, [text-equal], [comparing lengths]
+  length-equal?:bool <- equal a-len, b-len
+  return-unless length-equal?, 0/false
   # compare each corresponding character
   trace 99, [text-equal], [comparing characters]
   i:num <- copy 0
@@ -25,11 +22,8 @@ def equal a:text, b:text -> result:bool [
     break-if done?
     a2:char <- index *a, i
     b2:char <- index *b, i
-    {
-      chars-match?:bool <- equal a2, b2
-      break-if chars-match?
-      return 0
-    }
+    chars-match?:bool <- equal a2, b2
+    return-unless chars-match?, 0/false
     i <- add i, 1
     loop
   }
@@ -344,11 +338,8 @@ scenario append-to-buffer-of-non-characters [
 def buffer-to-array in:&:buffer:_elem -> result:&:@:_elem [
   local-scope
   load-ingredients
-  {
-    # propagate null buffer
-    break-if in
-    return 0
-  }
+  # propagate null buffer
+  return-unless in, 0
   len:num <- get *in, length:offset
   s:&:@:_elem <- get *in, data:offset
   # we can't just return s because it is usually the wrong length
@@ -995,13 +986,10 @@ def match-at text:text, pattern:text, idx:num -> result:bool [
   load-ingredients
   pattern-len:num <- length *pattern
   # check that there's space left for the pattern
-  {
-    x:num <- length *text
-    x <- subtract x, pattern-len
-    enough-room?:bool <- lesser-or-equal idx, x
-    break-if enough-room?
-    return 0/not-found
-  }
+  x:num <- length *text
+  x <- subtract x, pattern-len
+  enough-room?:bool <- lesser-or-equal idx, x
+  return-unless enough-room?, 0/not-found
   # check each character of pattern
   pattern-idx:num <- copy 0
   {
@@ -1009,11 +997,8 @@ def match-at text:text, pattern:text, idx:num -> result:bool [
     break-if done?
     c:char <- index *text, idx
     exp:char <- index *pattern, pattern-idx
-    {
-      match?:bool <- equal c, exp
-      break-if match?
-      return 0/not-found
-    }
+    match?:bool <- equal c, exp
+    return-unless match?, 0/not-found
     idx <- add idx, 1
     pattern-idx <- add pattern-idx, 1
     loop