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:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user