MCPcopy Create free account
hub / github.com/hoothin/UserScripts / fill_window

Function fill_window

Picviewer CE+/dist.user.js:6477–6622  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

6475 * option -- not supported here).
6476 */
6477function fill_window(s) {
6478 var _w_size = s.w_size;
6479 var p, n, m, more, str;
6480
6481 //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
6482
6483 do {
6484 more = s.window_size - s.lookahead - s.strstart;
6485
6486 // JS ints have 32 bit, block below not needed
6487 /* Deal with !@#$% 64K limit: */
6488 //if (sizeof(int) <= 2) {
6489 // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
6490 // more = wsize;
6491 //
6492 // } else if (more == (unsigned)(-1)) {
6493 // /* Very unlikely, but possible on 16 bit machine if
6494 // * strstart == 0 && lookahead == 1 (input done a byte at time)
6495 // */
6496 // more--;
6497 // }
6498 //}
6499
6500
6501 /* If the window is almost full and there is insufficient lookahead,
6502 * move the upper half to the lower one to make room in the upper half.
6503 */
6504 if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
6505
6506 utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
6507 s.match_start -= _w_size;
6508 s.strstart -= _w_size;
6509 /* we now have strstart >= MAX_DIST */
6510 s.block_start -= _w_size;
6511
6512 /* Slide the hash table (could be avoided with 32 bit values
6513 at the expense of memory usage). We slide even when level == 0
6514 to keep the hash table consistent if we switch back to level > 0
6515 later. (Using level 0 permanently is not an optimal usage of
6516 zlib, so we don't care about this pathological case.)
6517 */
6518
6519 n = s.hash_size;
6520 p = n;
6521 do {
6522 m = s.head[--p];
6523 s.head[p] = (m >= _w_size ? m - _w_size : 0);
6524 } while (--n);
6525
6526 n = _w_size;
6527 p = n;
6528 do {
6529 m = s.prev[--p];
6530 s.prev[p] = (m >= _w_size ? m - _w_size : 0);
6531 /* If n is not on any hash chain, prev[n] is garbage but
6532 * its value will never be used.
6533 */
6534 } while (--n);

Callers 6

deflate_storedFunction · 0.70
deflate_fastFunction · 0.70
deflate_slowFunction · 0.70
deflate_rleFunction · 0.70
deflate_huffFunction · 0.70
deflateSetDictionaryFunction · 0.70

Calls 1

read_bufFunction · 0.70

Tested by

no test coverage detected