Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3269a404
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3269a404
编写于
3月 02, 2012
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rewrite vec to be more unsafe, more inlined
上级
0416a946
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
2 deletion
+22
-2
src/libcore/ptr.rs
src/libcore/ptr.rs
+1
-0
src/libcore/uint.rs
src/libcore/uint.rs
+1
-0
src/libcore/vec.rs
src/libcore/vec.rs
+17
-2
src/rustc/metadata/csearch.rs
src/rustc/metadata/csearch.rs
+3
-0
未找到文件。
src/libcore/ptr.rs
浏览文件 @
3269a404
...
...
@@ -32,6 +32,7 @@ fn mut_addr_of<T>(val: T) -> *mutable T unsafe {
Calculate the offset from a pointer
*/
#[inline(always)]
fn
offset
<
T
>
(
ptr
:
*
T
,
count
:
uint
)
->
*
T
{
ret
rusti
::
ptr_offset
(
ptr
,
count
);
}
...
...
src/libcore/uint.rs
浏览文件 @
3269a404
...
...
@@ -131,6 +131,7 @@
Iterate over the range [`lo`..`hi`)
*/
#[inline(always)]
fn
range
(
lo
:
uint
,
hi
:
uint
,
it
:
fn
(
uint
))
{
let
i
=
lo
;
while
i
<
hi
{
it
(
i
);
i
+=
1u
;
}
...
...
src/libcore/vec.rs
浏览文件 @
3269a404
...
...
@@ -78,6 +78,7 @@ fn reserve<T>(&v: [const T], n: uint) {
Returns the length of a vector
*/
#[inline(always)]
pure
fn
len
<
T
>
(
v
:
[
const
T
])
->
uint
{
unchecked
{
rusti
::
vec_len
(
v
)
}
}
/*
...
...
@@ -885,9 +886,17 @@ fn enum_uints(start: uint, end: uint) -> [uint] {
element's value.
*/
#[inline]
#[inline
(always)
]
fn
iter
<
T
>
(
v
:
[
const
T
],
f
:
fn
(
T
))
{
iteri
(
v
)
{
|
_
i
,
v
|
f
(
v
)
}
unsafe
{
let
mut
n
=
vec
::
len
(
v
);
let
mut
p
=
unsafe
::
to_ptr
(
v
);
while
n
>
0u
{
f
(
*
p
);
p
=
ptr
::
offset
(
p
,
1u
);
n
-=
1u
;
}
}
}
/*
...
...
@@ -896,6 +905,7 @@ fn iter<T>(v: [const T], f: fn(T)) {
Iterates over two vectors in parallel
*/
#[inline]
fn
iter2
<
U
,
T
>
(
v
:
[
U
],
v2
:
[
const
T
],
f
:
fn
(
U
,
T
))
{
let
i
=
0
;
for
elt
in
v
{
f
(
elt
,
v2
[
i
]);
i
+=
1
;
}
...
...
@@ -909,6 +919,7 @@ fn iter2<U, T>(v: [ U], v2: [const T], f: fn(U, T)) {
Iterates over vector `v` and, for each element, calls function `f` with the
element's value and index.
*/
#[inline(always)]
fn
iteri
<
T
>
(
v
:
[
const
T
],
f
:
fn
(
uint
,
T
))
{
let
i
=
0u
,
l
=
len
(
v
);
while
i
<
l
{
f
(
i
,
v
[
i
]);
i
+=
1u
;
}
...
...
@@ -1001,6 +1012,7 @@ fn as_mut_buf<E,T>(v: [mutable E], f: fn(*mutable E) -> T) -> T unsafe {
}
impl
vec_len
<
T
>
for
[
T
]
{
#[inline(always)]
fn
len
()
->
uint
{
len
(
self
)
}
}
...
...
@@ -1020,6 +1032,7 @@ mod unsafe {
ptr - An unsafe pointer to a buffer of `T`
elts - The number of elements in the buffer
*/
#[inline(always)]
unsafe
fn
from_buf
<
T
>
(
ptr
:
*
T
,
elts
:
uint
)
->
[
T
]
{
ret
rustrt
::
vec_from_buf_shared
(
sys
::
get_type_desc
::
<
T
>
(),
ptr
,
elts
);
...
...
@@ -1034,6 +1047,7 @@ unsafe fn from_buf<T>(ptr: *T, elts: uint) -> [T] {
modifing its buffers, so it is up to the caller to ensure that
the vector is actually the specified size.
*/
#[inline(always)]
unsafe
fn
set_len
<
T
>
(
&
v
:
[
const
T
],
new_len
:
uint
)
{
let
repr
:
**
vec_repr
=
::
unsafe
::
reinterpret_cast
(
addr_of
(
v
));
(
**
repr
)
.fill
=
new_len
*
sys
::
size_of
::
<
T
>
();
...
...
@@ -1050,6 +1064,7 @@ unsafe fn set_len<T>(&v: [const T], new_len: uint) {
Modifying the vector may cause its buffer to be reallocated, which
would also make any pointers to it invalid.
*/
#[inline(always)]
unsafe
fn
to_ptr
<
T
>
(
v
:
[
const
T
])
->
*
T
{
let
repr
:
**
vec_repr
=
::
unsafe
::
reinterpret_cast
(
addr_of
(
v
));
ret
::
unsafe
::
reinterpret_cast
(
addr_of
((
**
repr
)
.data
));
...
...
src/rustc/metadata/csearch.rs
浏览文件 @
3269a404
...
...
@@ -72,6 +72,9 @@ fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path {
let
cstore
=
tcx
.sess.cstore
;
let
cdata
=
cstore
::
get_crate_data
(
cstore
,
def
.crate
);
let
path
=
decoder
::
get_item_path
(
cdata
,
def
.node
);
// FIXME #1920: This path is not always correct if the crate is not linked
// into the root namespace.
[
ast_map
::
path_mod
(
cdata
.name
)]
+
path
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录