Comments (3)
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.
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.
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)
- Issues from Fuchsia review HOT 1
- Const constructor for strings via a macro? HOT 3
- `insert` and `try_insert` for `ArrayString`? HOT 1
- having a TinyVec that fallback to heap HOT 4
- [feature] Implement `rayon::iter::FromParallelIterator` for `ArrayVec`.
- Consider `#[track_caller]` on functions that panic HOT 3
- [feature] Support picking the indexing type HOT 1
- Use `NonMaxU32` instead of `u32` as a length container to reduce `Option<ArrayVec>` size. HOT 12
- Miri doesn't accept same algorithm with `ArrayVec::retain` while accepting `Vec::retain` HOT 3
- Why is `ArrayVec::new_const` needed instead of having const `ArrayVec::new`? HOT 1
- Why are inherent associated functions of `ArrayVec` implemented via calls to trait-associated functions of `ArrayVecImpl` and not vice versa? HOT 1
- Add `From<[T; LEN]>` HOT 1
- Is this project still alive? HOT 6
- Feature request - tokio_postgres (FromSql and ToSql)
- Can I change `LenUint` to `u8`? HOT 2
- Add `ArrayString::from_utf8`
- Make `ArrayString::try_push(c: char)` smarter
- Better memory layout by moving len before xs HOT 3
- questions on use on constant context,
- Niche filling opportunity if len's alignment is less than T's alignment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrayvec.