summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-02-04 18:37:51 -0800
committerOri Bernstein <ori@eigenstate.org>2018-02-04 20:33:55 -0800
commitaec1d8a65052364f4946556e36d276b34e62bdcf (patch)
tree972a51f2d9703f58dd7c2715da980836de5deafb
parentf14bc15334c9a8527544f7f4b1be3a700274e02a (diff)
downloadmc-aec1d8a65052364f4946556e36d276b34e62bdcf.tar.gz
Free up regexes/strings after benchmark.
It's not important to do, but we want to be a good example for newbies.
-rw-r--r--bench/regex-match.myr16
1 files changed, 10 insertions, 6 deletions
diff --git a/bench/regex-match.myr b/bench/regex-match.myr
index bb268f2..78a31b4 100644
--- a/bench/regex-match.myr
+++ b/bench/regex-match.myr
@@ -6,12 +6,11 @@ var str
var dotstar, hello, world
const main = {
- str = std.sldup("hello world!")
- str = std.strcat(str, str)
- str = std.strcat(str, str)
- str = std.strcat(str, str)
- str = std.strcat(str, str)
- str = std.strcat(str, "x")
+ str = ""
+ for var i = 0; i < 16; i++
+ std.sljoin(&str, "hello world!")
+ ;;
+ std.sljoin(&str, "x")
dotstar = std.try(regex.compile(".*"))
hello = std.try(regex.compile("hel*o"))
@@ -22,6 +21,11 @@ const main = {
[.name="searchhello", .fn=searchhello],
[.name="searchworld", .fn=searchworld],
][:])
+
+ regex.free(dotstar)
+ regex.free(hello)
+ regex.free(world)
+ std.slfree(str)
}
const matchall = {ctx