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

Function updatewindow

Picviewer CE+/dist.user.js:8755–8795  ·  view source on GitHub ↗
(strm, src, end, copy)

Source from the content-addressed store, hash-verified

8753 The advantage may be dependent on the size of the processor's data caches.
8754 */
8755function updatewindow(strm, src, end, copy) {
8756 var dist;
8757 var state = strm.state;
8758
8759 /* if it hasn't been done already, allocate space for the window */
8760 if (state.window === null) {
8761 state.wsize = 1 << state.wbits;
8762 state.wnext = 0;
8763 state.whave = 0;
8764
8765 state.window = new utils.Buf8(state.wsize);
8766 }
8767
8768 /* copy state->wsize or less output bytes into the circular window */
8769 if (copy >= state.wsize) {
8770 utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
8771 state.wnext = 0;
8772 state.whave = state.wsize;
8773 }
8774 else {
8775 dist = state.wsize - state.wnext;
8776 if (dist > copy) {
8777 dist = copy;
8778 }
8779 //zmemcpy(state->window + state->wnext, end - copy, dist);
8780 utils.arraySet(state.window, src, end - copy, dist, state.wnext);
8781 copy -= dist;
8782 if (copy) {
8783 //zmemcpy(state->window, end - copy, copy);
8784 utils.arraySet(state.window, src, end - copy, copy, 0);
8785 state.wnext = copy;
8786 state.whave = state.wsize;
8787 }
8788 else {
8789 state.wnext += dist;
8790 if (state.wnext === state.wsize) { state.wnext = 0; }
8791 if (state.whave < state.wsize) { state.whave += dist; }
8792 }
8793 }
8794 return 0;
8795}
8796
8797function inflate(strm, flush) {
8798 var state;

Callers 2

inflateFunction · 0.70
inflateSetDictionaryFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected