Giter Club home page Giter Club logo

Comments (3)

bluss avatar bluss commented on August 17, 2024

Ideally, I think it should be removed in optimization. Is this something you found in an optimized build?

If the ArrayVec is not a struct field, then you can use std::mem::forget(array) directly (if it is empty or the elements have no destructor).

from arrayvec.

bluss avatar bluss commented on August 17, 2024

It looks like the memcpy / overwrite is not optimized out properly. We can automatically skip it, but only by using a nightly / unstable feature (std::intrinsics::needs_drop), but I've added a feature flag to crate nodrop called use_needs_drop that enables this.

To use it: Depend directly on crate nodrop, enable feature flag use_needs_drop for nodrop. To only do it temporarily you can use --features=nodrop/use_needs_drop.

Of course, the big memcpy is redundant (only a small part needs to be overwritten to set the flag that inhibits drop, but it's the cleanest way to implement it. Maybe we can improve it..

from arrayvec.

y-ich avatar y-ich commented on August 17, 2024

Thank you for your advice.
As you mentioned, I was confused because memcpys appear in some functions and does not appear in some other functions, and now I understood as instability of optimization.

I will see std::mem::forget(array) at first.

Thank you!

from arrayvec.

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.