Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uninit intrinsic. Use in core::vec #4204

Closed
brson opened this issue Dec 16, 2012 · 3 comments
Closed

Add uninit intrinsic. Use in core::vec #4204

brson opened this issue Dec 16, 2012 · 3 comments
Labels
A-codegen Area: Code generation E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Dec 16, 2012

vec previously had some code that looked like this:

let vp: *T = ...;
let v = move *vp;

This had the effect of memcpying *vp to v and zeroing *vp. move is being removed so this doesn't work. I've replaced that with:

let mut vp: *T = ...;
let mut v: T = rusti::init(); // Create a zeroed value
v <-> *vp;

This could probably be more efficient by 1) not zeroing the value (in most cases), 2) not doing the swap.

Probably this is what we should do:

let mut vp: *T = ...;
let mut v: T = rusti::uninit(); // Create a non-zeroed value
ptr:memcpy(&mut T, vp, 1);

And if you need the zeroing you can do a memset.

@graydon
Copy link
Contributor

graydon commented Mar 20, 2013

non-critical for 0.6, de-milestoning

@sanxiyn
Copy link
Member

sanxiyn commented May 6, 2013

This seems to be a duplicate of #3471.

@Aatch
Copy link
Contributor

Aatch commented May 10, 2013

Closed by #6354

@Aatch Aatch closed this as completed May 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants