Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2ba7729a
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,发现更多精彩内容 >>
提交
2ba7729a
编写于
6月 18, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Cache results of type_has_pointers. 70% translation speedup.
上级
b2bcafe6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
21 deletion
+27
-21
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+27
-21
未找到文件。
src/comp/middle/ty.rs
浏览文件 @
2ba7729a
...
...
@@ -65,6 +65,7 @@
type_cache
tcache
,
creader_cache
rcache
,
hashmap
[
t
,
str
]
short_names_cache
,
hashmap
[
t
,
bool
]
has_pointer_cache
,
hashmap
[
@
ast
::
ty
,
option
::
t
[
t
]]
ast_ty_to_ty_cache
);
type
ty_ctxt
=
ctxt
;
...
...
@@ -264,6 +265,8 @@ fn mk_ctxt(session::session s, resolve::def_map dm, constr_table cs) -> ctxt {
rcache
=
mk_rcache
(),
short_names_cache
=
map
::
mk_hashmap
[
ty
::
t
,
str
](
ty
::
hash_ty
,
ty
::
eq_ty
),
has_pointer_cache
=
map
::
mk_hashmap
[
ty
::
t
,
bool
](
ty
::
hash_ty
,
ty
::
eq_ty
),
ast_ty_to_ty_cache
=
map
::
mk_hashmap
[
@
ast
::
ty
,
option
::
t
[
t
]](
ast
::
hash_ty
,
ast
::
eq_ty
));
...
...
@@ -836,32 +839,33 @@ fn type_is_scalar(&ctxt cx, &t ty) -> bool {
}
fn
type_has_pointers
(
&
ctxt
cx
,
&
t
ty
)
->
bool
{
alt
(
cx
.has_pointer_cache
.find
(
ty
))
{
case
(
some
(
?
result
))
{
ret
result
;
}
case
(
none
)
{
/* fall through */
}
}
auto
result
=
false
;
alt
(
struct
(
cx
,
ty
))
{
case
(
// scalar types
ty_nil
)
{
ret
false
;
}
case
(
ty_bot
)
{
ret
false
;
}
case
(
ty_bool
)
{
ret
false
;
}
case
(
ty_int
)
{
ret
false
;
}
case
(
ty_float
)
{
ret
false
;
}
case
(
ty_uint
)
{
ret
false
;
}
case
(
ty_machine
(
_
))
{
ret
false
;
}
case
(
ty_char
)
{
ret
false
;
}
case
(
ty_type
)
{
ret
false
;
}
case
(
ty_native
)
{
ret
false
;
}
// scalar types
case
(
ty_nil
)
{
/* no-op */
}
case
(
ty_bot
)
{
/* no-op */
}
case
(
ty_bool
)
{
/* no-op */
}
case
(
ty_int
)
{
/* no-op */
}
case
(
ty_float
)
{
/* no-op */
}
case
(
ty_uint
)
{
/* no-op */
}
case
(
ty_machine
(
_
))
{
/* no-op */
}
case
(
ty_char
)
{
/* no-op */
}
case
(
ty_type
)
{
/* no-op */
}
case
(
ty_native
)
{
/* no-op */
}
case
(
ty_tup
(
?
elts
))
{
for
(
mt
m
in
elts
)
{
if
(
type_has_pointers
(
cx
,
m
.ty
))
{
re
t
true
;
}
if
(
type_has_pointers
(
cx
,
m
.ty
))
{
re
sult
=
true
;
}
}
ret
false
;
}
case
(
ty_rec
(
?
flds
))
{
for
(
field
f
in
flds
)
{
if
(
type_has_pointers
(
cx
,
f
.mt.ty
))
{
re
t
true
;
}
if
(
type_has_pointers
(
cx
,
f
.mt.ty
))
{
re
sult
=
true
;
}
}
ret
false
;
}
case
(
ty_tag
(
?
did
,
?
tps
))
{
auto
variants
=
tag_variants
(
cx
,
did
);
...
...
@@ -870,12 +874,14 @@ fn type_has_pointers(&ctxt cx, &t ty) -> bool {
// Perform any type parameter substitutions.
tup_ty
=
substitute_type_params
(
cx
,
tps
,
tup_ty
);
if
(
type_has_pointers
(
cx
,
tup_ty
))
{
re
t
true
;
}
if
(
type_has_pointers
(
cx
,
tup_ty
))
{
re
sult
=
true
;
}
}
ret
false
;
}
case
(
_
)
{
re
t
true
;
}
case
(
_
)
{
re
sult
=
true
;
}
}
cx
.has_pointer_cache
.insert
(
ty
,
result
);
ret
result
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录