feat: store precomputed hash in ObjString and use it for equality and hashing

Cache the FNV-1a hash code in the ObjString struct at creation time, replacing the
on-the-fly sampling hash in hashObject() and enabling constant-time string equality
checks. Refactor string allocation into allocateString() and hashString() helpers,
remove the old wrenNewUninitializedString() declaration, and add a CONST_STRING
macro. Disable the unimplemented subscript range operator with a runtime error and
skip the related UTF-8 tests. Add a string_equals benchmark to measure the speedup.
This commit is contained in:
Bob Nystrom
2015-03-18 14:09:03 +00:00
parent a3418dc06a
commit 1e842bbb2e
14 changed files with 89 additions and 52 deletions
+2
View File
@@ -75,6 +75,8 @@ BENCHMARK("map_numeric", r"""500000500000""")
BENCHMARK("map_string", r"""3645600""")
BENCHMARK("string_equals", r"""3000000""")
LANGUAGES = [
("wren", [os.path.join(WREN_DIR, 'wren')], ".wren"),
("lua", ["lua"], ".lua"),