Giter Site home page Giter Site logo

Removal about chunky-vec HOT 4 OPEN

zbraniecki avatar zbraniecki commented on June 2, 2024
Removal

from chunky-vec.

Comments (4)

djg avatar djg commented on June 2, 2024

I feel like for safety aspects I should check with @Manishearth, but the intention is that ChunkyVec is mostly push only. I copied this from the elsa types.

Since the storage for ChunkyVec is chunked, and not a Vec, it should be okay to replace items already allocated as well as supporting pop. removeSources() in L10nRegistry.jsm might be a bit hard to implement given the constraints. This is where the elsa types keep the element boxed so it's address is stable and it's possible to then re-arrange the underlying Vec.

Alternatively, is it possible to store Option<T> in the ChunkyVec? Removal would then None the element and source checking logic would need to skip those.

WDYT, @zbraniecki?

from chunky-vec.

zbraniecki avatar zbraniecki commented on June 2, 2024

Using Option would mean that for i in 0..10 { registerSource;removeSource;} would result in 10 element ChunkyVec with empty elements.
I'd prefer to avoid that if possible.

Do you think that this is the best we can do with ChunkyVec?

from chunky-vec.

djg avatar djg commented on June 2, 2024

Do you think that this is the best we can do with ChunkyVec?

At the moment, unfortunately, yes, with out adding logic inside ChunkyVec so that it becomes more like slab.

Would it be possible to add the add/remove functionality into a thin wrapper over ChunkyVec<Option<T>> type in L10nRegistry? (Or can we add impls only for ChunkyVec<Option<T>>? I'd be open to that, unless someone with more Rust soundness experience tells me it's wrong)

from chunky-vec.

Manishearth avatar Manishearth commented on June 2, 2024

Yeah append-only collections have a lot of good properties for performance and safety, deletion makes it harder. slab is indeed a good option here

Thin wrapper is another.

from chunky-vec.

Related Issues (2)

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.