Skip to content

Commit 55cc6ea

Browse files
committed
---
yaml --- r: 12018 b: refs/heads/master c: bc3f5e7 h: refs/heads/master v: v3
1 parent 8f893c7 commit 55cc6ea

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: cce2751461729147ecdbf514e6df6a7052f8f6af
2+
refs/heads/master: bc3f5e716039b8f41f31f30fe3769390a298e78d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/ptr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export memmove;
1212
#[abi = "rust-intrinsic"]
1313
native mod rusti {
1414
fn addr_of<T>(val: T) -> *T;
15-
fn ptr_offset<T>(ptr: *T, count: libc::uintptr_t) -> *T;
1615
fn memcpy<T>(dst: *T, src: *T, count: libc::uintptr_t);
1716
fn memmove<T>(dst: *T, src: *T, count: libc::uintptr_t);
1817
}
@@ -29,14 +28,14 @@ fn mut_addr_of<T>(val: T) -> *mutable T unsafe {
2928

3029
#[doc = "Calculate the offset from a pointer"]
3130
#[inline(always)]
32-
fn offset<T>(ptr: *T, count: uint) -> *T {
33-
ret rusti::ptr_offset(ptr, count);
31+
fn offset<T>(ptr: *T, count: uint) -> *T unsafe {
32+
(ptr as uint + count * sys::size_of::<T>()) as *T
3433
}
3534

3635
#[doc = "Calculate the offset from a mutable pointer"]
3736
#[inline(always)]
3837
fn mut_offset<T>(ptr: *mutable T, count: uint) -> *mutable T {
39-
ret rusti::ptr_offset(ptr as *T, count) as *mutable T;
38+
(ptr as uint + count * sys::size_of::<T>()) as *mutable T
4039
}
4140

4241

trunk/src/libcore/vec.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ export vec_len;
7474
export unsafe;
7575
export u8;
7676

77-
#[abi = "rust-intrinsic"]
78-
native mod rusti {
79-
fn vec_len<T>(&&v: [const T]) -> libc::size_t;
80-
}
81-
8277
#[abi = "cdecl"]
8378
native mod rustrt {
8479
fn vec_reserve_shared<T>(t: *sys::type_desc,
@@ -122,7 +117,10 @@ fn reserve<T>(&v: [const T], n: uint) {
122117

123118
#[doc = "Returns the length of a vector"]
124119
#[inline(always)]
125-
pure fn len<T>(v: [const T]) -> uint { unchecked { rusti::vec_len(v) } }
120+
pure fn len<T>(&&v: [const T]) -> uint unsafe {
121+
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
122+
(**repr).fill / sys::size_of::<T>()
123+
}
126124

127125
#[doc = "
128126
Creates and initializes an immutable vector.

0 commit comments

Comments
 (0)