shithub: mc

Download patch

ref: aec1d8a65052364f4946556e36d276b34e62bdcf
parent: f14bc15334c9a8527544f7f4b1be3a700274e02a
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Feb 4 13:37:51 EST 2018

Free up regexes/strings after benchmark.

	It's not important to do, but we want to be a good
	example for newbies.

--- a/bench/regex-match.myr
+++ b/bench/regex-match.myr
@@ -6,12 +6,11 @@
 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 @@
 		[.name="searchhello", .fn=searchhello],
 		[.name="searchworld", .fn=searchworld],
 	][:])
+
+	regex.free(dotstar)
+	regex.free(hello)
+	regex.free(world)
+	std.slfree(str)
 }
 
 const matchall = {ctx