function zip_fill_window()

in themes/docsy/static/js/deflate.js [502:551]


    function zip_fill_window() {
        var n, m;

        // Amount of free space at the end of the window.
        var more = zip_window_size - zip_lookahead - zip_strstart;

        /* If the window is almost full and there is insufficient lookahead,
            * move the upper half to the lower one to make room in the upper half.
            */
        if (more == -1) {
            /* Very unlikely, but possible on 16 bit machine if strstart == 0
                    * and lookahead == 1 (input done one byte at time)
                    */
            more--;
        } else if (zip_strstart >= zip_WSIZE + zip_MAX_DIST) {
            /* By the IN assertion, the window is not empty so we can't confuse
                    * more == 0 with more == 64K on a 16 bit machine.
                    */
            //	Assert(window_size == (ulg)2*WSIZE, "no sliding with BIG_MEM");

            //	System.arraycopy(window, WSIZE, window, 0, WSIZE);
            for (n = 0; n < zip_WSIZE; n++)
                zip_window[n] = zip_window[n + zip_WSIZE];

            zip_match_start -= zip_WSIZE;
            zip_strstart -= zip_WSIZE; /* we now have strstart >= MAX_DIST: */
            zip_block_start -= zip_WSIZE;

            for (n = 0; n < zip_HASH_SIZE; n++) {
                m = zip_head1(n);
                zip_head2(n, m >= zip_WSIZE ? m - zip_WSIZE : zip_NIL);
            }
            for (n = 0; n < zip_WSIZE; n++) {
                /* If n is not on any hash chain, prev[n] is garbage but
                    * its value will never be used.
                    */
                m = zip_prev[n];
                zip_prev[n] = (m >= zip_WSIZE ? m - zip_WSIZE : zip_NIL);
            }
            more += zip_WSIZE;
        }
        // At this point, more >= 2
        if (!zip_eofile) {
            n = zip_read_buff(zip_window, zip_strstart + zip_lookahead, more);
            if (n <= 0)
                zip_eofile = true;
            else
                zip_lookahead += n;
        }
    }