GithubHelp home page GithubHelp logo

Comments (4)

101arrowz avatar 101arrowz commented on June 9, 2024

The output buffer option is provided specifically so that the function does not reallocate at all, so this is probably a bug. I'll verify that I can reproduce and fix it in the next release.

from fflate.

sigurdle avatar sigurdle commented on June 9, 2024

I just double checked by passing in my own buffer that is 1 byte more than the uncompressed size, and it results in a new Uint8Array

Last line in "inflt"
return bt == buf.length ? buf : slc(buf, 0, bt);

// typed array slice - allows garbage collector to free original reference,
// while being more compatible than .slice
var slc = function (v, s, e) {
    if (s == null || s < 0)
        s = 0;
    if (e == null || e > v.length)
        e = v.length;
    // can't use .constructor in case user-supplied
    var n = new u8(e - s);
    n.set(v.subarray(s, e));
    return n;
};

Those two last lines I think would be more efficient with
var n = new u8(v.subarray(s, e)); // no 0-initialization necessary

last line in inflt could maybe be:

return bt == buf.length ? buf:
(!noBuf)? buf.subarray(0,bt):  slc(buf, 0, bt);

or something like that

from fflate.

101arrowz avatar 101arrowz commented on June 9, 2024

That is exactly the approach I had in mind. Will release in v0.8.1.

from fflate.

101arrowz avatar 101arrowz commented on June 9, 2024

Released in v0.8.1.

from fflate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.