Skip to content

Commit 9c76574

Browse files
authored
Remove dead code from src/deterministic.js. NFC (#26618)
The `hashMemory` function was added back 2013 (156fe33) but has never had any testing of documenation. The `hashString` function was added in 2015 (e1344f0) also without any testing of example uses. I'm hoping to simply remove the `-sDETERMINISTIC` setting, but as part of that I'm first trying to strip it down to whats actually used/tested.
1 parent 9a23e37 commit 9c76574

2 files changed

Lines changed: 3 additions & 21 deletions

File tree

src/deterministic.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,5 @@ Date.now = deterministicNow;
2323
// See getPerformanceNow in parseTools.mjs for how we deal with this.
2424
if (globalThis.performance) performance.now = deterministicNow;
2525

26-
Module['thisProgram'] = 'thisProgram'; // for consistency between different builds than between runs of the same build
27-
28-
function hashMemory(id) {
29-
var ret = 0;
30-
var len = _sbrk(0);
31-
for (var i = 0; i < len; i++) {
32-
ret = (ret*17 + HEAPU8[i])|0;
33-
}
34-
return id + ':' + ret;
35-
}
36-
37-
function hashString(s) {
38-
var ret = 0;
39-
for (var i = 0; i < s.length; i++) {
40-
ret = (ret*17 + s.charCodeAt(i))|0;
41-
}
42-
return ret;
43-
}
44-
26+
// for consistency between different builds than between runs of the same build
27+
Module['thisProgram'] = 'thisProgram';

tools/link.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,7 @@ def limit_incoming_module_api():
12861286
settings.ALLOW_TABLE_GROWTH = 1
12871287

12881288
# various settings require sbrk() access
1289-
if settings.DETERMINISTIC or \
1290-
settings.EMSCRIPTEN_TRACING or \
1289+
if settings.EMSCRIPTEN_TRACING or \
12911290
settings.SAFE_HEAP or \
12921291
settings.MEMORYPROFILER:
12931292
settings.REQUIRED_EXPORTS += ['sbrk']

0 commit comments

Comments
 (0)