(view: DataView, length: number, c: number)
| 237 | } |
| 238 | |
| 239 | function hash32(view: DataView, length: number, c: number): number { |
| 240 | let a = 0x9e3779b9, |
| 241 | b = 0x9e3779b9; |
| 242 | let index = 0; |
| 243 | |
| 244 | const end = length - 12; |
| 245 | for (; index <= end; index += 12) { |
| 246 | a += view.getUint32(index, true); |
| 247 | b += view.getUint32(index + 4, true); |
| 248 | c += view.getUint32(index + 8, true); |
| 249 | const res = mix(a, b, c); |
| 250 | ((a = res[0]), (b = res[1]), (c = res[2])); |
| 251 | } |
| 252 | |
| 253 | const remainder = length - index; |
| 254 | |
| 255 | // the first byte of c is reserved for the length |
| 256 | c += length; |
| 257 | |
| 258 | if (remainder >= 4) { |
| 259 | a += view.getUint32(index, true); |
| 260 | index += 4; |
| 261 | |
| 262 | if (remainder >= 8) { |
| 263 | b += view.getUint32(index, true); |
| 264 | index += 4; |
| 265 | |
| 266 | // Partial 32-bit word for c |
| 267 | if (remainder >= 9) { |
| 268 | c += view.getUint8(index++) << 8; |
| 269 | } |
| 270 | if (remainder >= 10) { |
| 271 | c += view.getUint8(index++) << 16; |
| 272 | } |
| 273 | if (remainder === 11) { |
| 274 | c += view.getUint8(index++) << 24; |
| 275 | } |
| 276 | } else { |
| 277 | // Partial 32-bit word for b |
| 278 | if (remainder >= 5) { |
| 279 | b += view.getUint8(index++); |
| 280 | } |
| 281 | if (remainder >= 6) { |
| 282 | b += view.getUint8(index++) << 8; |
| 283 | } |
| 284 | if (remainder === 7) { |
| 285 | b += view.getUint8(index++) << 16; |
| 286 | } |
| 287 | } |
| 288 | } else { |
| 289 | // Partial 32-bit word for a |
| 290 | if (remainder >= 1) { |
| 291 | a += view.getUint8(index++); |
| 292 | } |
| 293 | if (remainder >= 2) { |
| 294 | a += view.getUint8(index++) << 8; |
| 295 | } |
| 296 | if (remainder === 3) { |
no test coverage detected
searching dependent graphs…