Skip to content

Commit f5ab112

Browse files
author
James Miller
committed
Replace init() with uninit() where appropriate
1 parent 050c744 commit f5ab112

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

src/libcore/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub mod rusti {
2525

2626
/// Casts the value at `src` to U. The two types must have the same length.
2727
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
28-
let mut dest: U = unstable::intrinsics::init();
28+
let mut dest: U = unstable::intrinsics::uninit();
2929
{
3030
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
3131
let src_ptr: *u8 = rusti::transmute(src);

src/libcore/vec.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T {
591591
}
592592
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
593593
unsafe {
594-
// FIXME #4204: Should be uninit() - we don't need this zeroed
595-
let mut val = intrinsics::init();
594+
let mut val = intrinsics::uninit();
596595
val <-> *valptr;
597596
raw::set_len(v, ln - 1u);
598597
val
@@ -666,8 +665,7 @@ pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
666665
unsafe {
667666
do as_mut_buf(rhs) |p, len| {
668667
for uint::range(0, len) |i| {
669-
// FIXME #4204 Should be uninit() - don't need to zero
670-
let mut x = intrinsics::init();
668+
let mut x = intrinsics::uninit();
671669
x <-> *ptr::mut_offset(p, i);
672670
push(&mut *v, x);
673671
}
@@ -683,8 +681,7 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
683681
unsafe {
684682
// This loop is optimized out for non-drop types.
685683
for uint::range(newlen, oldlen) |i| {
686-
// FIXME #4204 Should be uninit() - don't need to zero
687-
let mut dropped = intrinsics::init();
684+
let mut dropped = intrinsics::uninit();
688685
dropped <-> *ptr::mut_offset(p, i);
689686
}
690687
}
@@ -709,9 +706,7 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
709706
// last_written < next_to_read < ln
710707
if *ptr::mut_offset(p, next_to_read) ==
711708
*ptr::mut_offset(p, last_written) {
712-
// FIXME #4204 Should be uninit() - don't need to
713-
// zero
714-
let mut dropped = intrinsics::init();
709+
let mut dropped = intrinsics::uninit();
715710
dropped <-> *ptr::mut_offset(p, next_to_read);
716711
} else {
717712
last_written += 1;

src/libstd/priority_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub impl <T:Ord> PriorityQueue<T> {
139139
while pos > start {
140140
let parent = (pos - 1) >> 1;
141141
if new > self.data[parent] {
142-
let mut x = rusti::init();
142+
let mut x = rusti::uninit();
143143
x <-> self.data[parent];
144144
rusti::move_val_init(&mut self.data[pos], x);
145145
pos = parent;
@@ -162,7 +162,7 @@ pub impl <T:Ord> PriorityQueue<T> {
162162
if right < end && !(self.data[child] > self.data[right]) {
163163
child = right;
164164
}
165-
let mut x = rusti::init();
165+
let mut x = rusti::uninit();
166166
x <-> self.data[child];
167167
rusti::move_val_init(&mut self.data[pos], x);
168168
pos = child;

src/libstd/rc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<T: Owned> Drop for Rc<T> {
5151
unsafe {
5252
(*self.ptr).count -= 1;
5353
if (*self.ptr).count == 0 {
54-
let mut x = intrinsics::init();
54+
let mut x = intrinsics::uninit();
5555
x <-> *self.ptr;
5656
free(self.ptr as *c_void)
5757
}
@@ -159,7 +159,7 @@ impl<T: Owned> Drop for RcMut<T> {
159159
unsafe {
160160
(*self.ptr).count -= 1;
161161
if (*self.ptr).count == 0 {
162-
let mut x = rusti::init();
162+
let mut x = rusti::uninit();
163163
x <-> *self.ptr;
164164
free(self.ptr as *c_void)
165165
}

0 commit comments

Comments
 (0)