mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
393 B
16 lines
393 B
/* Trivial string checksum used to summarize brute force output lines
|
|
* (minimizes test case size).
|
|
*/
|
|
function checksumString(x) {
|
|
var i, n;
|
|
var res = 0;
|
|
var mult = [ 1, 3, 5, 7, 11, 13, 17, 19, 23 ];
|
|
|
|
n = x.length;
|
|
for (i = 0; i < n; i++) {
|
|
res += x.charCodeAt(i) * mult[i % mult.length];
|
|
res = res >>> 0; // coerce to 32 bits
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|