Store hash code in strings.

Makes string equality and string map keys much faster.
Also did some other general string clean-up.
This commit is contained in:
Bob Nystrom
2015-03-18 07:09:03 -07:00
parent b80ba29b0e
commit be11d09bd8
14 changed files with 89 additions and 52 deletions
+24
View File
@@ -0,0 +1,24 @@
var start = IO.clock
var count = 0
for (i in 1..1000000) {
if ("abc" == "abc") count = count + 1
if ("a slightly longer string" ==
"a slightly longer string") count = count + 1
if ("a significantly longer string but still not overwhelmingly long string" ==
"a significantly longer string but still not overwhelmingly long string") count = count + 1
if ("" == "abc") count = count + 1
if ("abc" == "abcd") count = count + 1
if ("changed one character" == "changed %ne character") count = count + 1
if ("123" == 123) count = count + 1
if ("a slightly longer string" ==
"a slightly longer string!") count = count + 1
if ("a slightly longer string" ==
"a slightly longer strinh") count = count + 1
if ("a significantly longer string but still not overwhelmingly long string" ==
"another") count = count + 1
}
IO.print(count)
IO.print("elapsed: ", IO.clock - start)