Git Product home page Git Product logo

Comments (3)

dcodeIO avatar dcodeIO commented on June 17, 2024

Currently, instances are meant to be immutable, which for example allows Long.js (as well as goog.math.long which it is based upon) to maintain a cache of small integer values (i.e. to reduce garbage, see). I rather think of a Long as a type replacement here, not as a library.

Also, with modern JS engines, Longs shouldn't be much of a memory problem. Each one basically is a plain object with two numbers (always explicitly cast to a 32bit int) and a bool as its properties. This is (at least I expect that) what engines have been optimized for, so optimizing this any further might make things a bit faster indeed, but might also make it a bit worse, for example if additional local variables are required.

Not exactly sure, though. A concrete test case showing the differences would be ideal.

from long.js.

kriskowal avatar kriskowal commented on June 17, 2024

Yeah, it is pretty clear that interned longs would need to be immutable and that might make more of a mess of the interface than it would help. I implemented self-mutation in ndim to get ahead of the GC losing game for front-end animation, since GC pauses plague smooth animation. It is not clear at this time whether this is a problem we will have with Long, so it would be (maybe) premature to go forth and implement this. I’ll defer the issue for now.

from long.js.

dcodeIO avatar dcodeIO commented on June 17, 2024

As this came up a couple of times recently, I tested out a couple of ideas in 59a3dbd but only ended up with https://github.com/dcodeIO/long.js/blob/master/src/long.js#L312

from long.js.

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.