ref: 097c5188b37949e352cb8c92b38c49b4027314e0
parent: 358de40c2f56409ced4d76cd2c4201c609457dac
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Dec 28 20:31:31 EST 2017
Benchmark matching at end of string.
--- a/bench/regex-match.myr
+++ b/bench/regex-match.myr
@@ -3,7 +3,7 @@
use testr
var str
-var dotstar, hello
+var dotstar, hello, world
const main = {
str = std.sldup("hello world!")
@@ -11,13 +11,16 @@
str = std.strcat(str, str)
str = std.strcat(str, str)
str = std.strcat(str, str)
+ str = std.strcat(str, "x")
dotstar = std.try(regex.compile(".*"))
hello = std.try(regex.compile("hel*o"))
+ world = std.try(regex.compile("wor*l*d!x"))
testr.bench([
[.name="matchall", .fn=matchall],
[.name="searchhello", .fn=searchhello],
+ [.name="searchworld", .fn=searchworld],
][:])
}
@@ -30,6 +33,13 @@
const searchhello = {ctx
match regex.search(hello, str)
+ | `std.Some m: regex.matchfree(m)
+ | `std.None: std.fatal("Didn't match regex\n")
+ ;;
+}
+
+const searchworld = {ctx
+ match regex.search(world, str)
| `std.Some m: regex.matchfree(m)
| `std.None: std.fatal("Didn't match regex\n")
;;
--- a/lib/regex/interp.myr
+++ b/lib/regex/interp.myr
@@ -364,7 +364,7 @@
die(re, thr)
;;
| _:
- std.die("bad match")
+ std.die("corrupt regex bytecode")
;;
-> true
}