Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7f0fa143
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,发现更多精彩内容 >>
提交
7f0fa143
编写于
1月 23, 2013
作者:
D
Daniel Micay
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
switch LinearMap to current constructor convention
上级
591eefd7
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
37 addition
and
33 deletion
+37
-33
src/libcargo/cargo.rc
src/libcargo/cargo.rc
+3
-3
src/libcore/hashmap.rs
src/libcore/hashmap.rs
+15
-11
src/libstd/json.rs
src/libstd/json.rs
+8
-8
src/libstd/net_url.rs
src/libstd/net_url.rs
+4
-4
src/libstd/workcache.rs
src/libstd/workcache.rs
+5
-5
src/test/bench/core-map.rs
src/test/bench/core-map.rs
+2
-2
未找到文件。
src/libcargo/cargo.rc
浏览文件 @
7f0fa143
...
...
@@ -1617,7 +1617,7 @@ fn dump_cache(c: &Cargo) {
need_dir(&c.root);
let out = c.root.push("cache.json");
let _root = json::Object(~LinearMap());
let _root = json::Object(~LinearMap
::new
());
if os::path_exists(&out) {
copy_warn(&out, &c.root.push("cache.json.old"));
...
...
@@ -1638,10 +1638,10 @@ fn dump_sources(c: &Cargo) {
match io::buffered_file_writer(&out) {
result::Ok(writer) => {
let mut hash = ~LinearMap();
let mut hash = ~LinearMap
::new
();
for c.sources.each |k, v| {
let mut chash = ~LinearMap();
let mut chash = ~LinearMap
::new
();
chash.insert(~"url", json::String(v.url));
chash.insert(~"method", json::String(v.method));
...
...
src/libcore/hashmap.rs
浏览文件 @
7f0fa143
...
...
@@ -352,6 +352,10 @@ fn remove(&mut self, k: &K) -> bool {
}
impl
<
K
:
Hash
IterBytes
Eq
,
V
>
LinearMap
<
K
,
V
>
{
static
fn
new
()
->
LinearMap
<
K
,
V
>
{
linear_map_with_capacity
(
INITIAL_CAPACITY
)
}
fn
pop
(
&
mut
self
,
k
:
&
K
)
->
Option
<
V
>
{
let
hash
=
k
.hash_keyed
(
self
.k0
,
self
.k1
)
as
uint
;
self
.pop_internal
(
hash
,
k
)
...
...
@@ -405,7 +409,7 @@ fn consume(&mut self, f: fn(K, V)) {
}
}
impl
<
K
:
Hash
IterBytes
Eq
,
V
:
Copy
>
LinearMap
<
K
,
V
>
{
impl
<
K
:
Hash
IterBytes
Eq
,
V
:
Copy
>
LinearMap
<
K
,
V
>
{
pure
fn
find_copy
(
&
const
self
,
k
:
&
K
)
->
Option
<
V
>
{
match
self
.bucket_for_key
(
self
.buckets
,
k
)
{
FoundEntry
(
idx
)
=>
{
...
...
@@ -504,7 +508,7 @@ pub mod test {
#[test]
pub
fn
inserts
()
{
let
mut
m
=
~
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
assert
m
.insert
(
1
,
2
);
assert
m
.insert
(
2
,
4
);
assert
*
m
.get
(
&
1
)
==
2
;
...
...
@@ -513,7 +517,7 @@ pub fn inserts() {
#[test]
pub
fn
overwrite
()
{
let
mut
m
=
~
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
assert
m
.insert
(
1
,
2
);
assert
*
m
.get
(
&
1
)
==
2
;
assert
!
m
.insert
(
1
,
3
);
...
...
@@ -553,7 +557,7 @@ pub fn empty() {
#[test]
pub
fn
pops
()
{
let
mut
m
=
~
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
m
.insert
(
1
,
2
);
assert
m
.pop
(
&
1
)
==
Some
(
2
);
assert
m
.pop
(
&
1
)
==
None
;
...
...
@@ -561,7 +565,7 @@ pub fn pops() {
#[test]
pub
fn
swaps
()
{
let
mut
m
=
~
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
assert
m
.swap
(
1
,
2
)
==
None
;
assert
m
.swap
(
1
,
3
)
==
Some
(
2
);
assert
m
.swap
(
1
,
4
)
==
Some
(
3
);
...
...
@@ -569,10 +573,10 @@ pub fn swaps() {
#[test]
pub
fn
consumes
()
{
let
mut
m
=
~
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
assert
m
.insert
(
1
,
2
);
assert
m
.insert
(
2
,
3
);
let
mut
m2
=
~
LinearMap
();
let
mut
m2
=
LinearMap
::
new
();
do
m
.consume
|
k
,
v
|
{
m2
.insert
(
k
,
v
);
}
...
...
@@ -598,7 +602,7 @@ pub fn iterate() {
#[test]
pub
fn
find
()
{
let
mut
m
=
~
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
assert
m
.find
(
&
1
)
.is_none
();
m
.insert
(
1
,
2
);
match
m
.find
(
&
1
)
{
...
...
@@ -609,12 +613,12 @@ pub fn find() {
#[test]
pub
fn
test_eq
()
{
let
mut
m1
=
~
LinearMap
();
let
mut
m1
=
LinearMap
::
new
();
m1
.insert
(
1
,
2
);
m1
.insert
(
2
,
3
);
m1
.insert
(
3
,
4
);
let
mut
m2
=
~
LinearMap
();
let
mut
m2
=
LinearMap
::
new
();
m2
.insert
(
1
,
2
);
m2
.insert
(
2
,
3
);
...
...
@@ -627,7 +631,7 @@ pub fn test_eq() {
#[test]
pub
fn
test_expand
()
{
let
mut
m
=
~
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
assert
m
.len
()
==
0
;
assert
m
.is_empty
();
...
...
src/libstd/json.rs
浏览文件 @
7f0fa143
...
...
@@ -24,7 +24,7 @@
use
core
::
io
::{
WriterUtil
,
ReaderUtil
};
use
core
::
io
;
use
core
::
prelude
::
*
;
use
core
::
hashmap
::
linear
;
use
core
::
hashmap
::
linear
::
LinearMap
;
use
core
::
str
;
use
core
::
to_str
;
use
core
::
vec
;
...
...
@@ -40,7 +40,7 @@ pub enum Json {
}
pub
type
List
=
~
[
Json
];
pub
type
Object
=
linear
::
LinearMap
<~
str
,
Json
>
;
pub
type
Object
=
LinearMap
<~
str
,
Json
>
;
pub
struct
Error
{
line
:
uint
,
...
...
@@ -671,7 +671,7 @@ fn parse_object() -> Result<Json, Error> {
self
.bump
();
self
.parse_whitespace
();
let
mut
values
=
~
linear
::
LinearMap
();
let
mut
values
=
~
LinearMap
::
new
();
if
self
.ch
==
'}'
{
self
.bump
();
...
...
@@ -1175,9 +1175,9 @@ impl <A: ToJson> ~[A]: ToJson {
fn
to_json
()
->
Json
{
List
(
self
.map
(|
elt
|
elt
.to_json
()))
}
}
impl
<
A
:
ToJson
Copy
>
linear
::
LinearMap
<~
str
,
A
>
:
ToJson
{
impl
<
A
:
ToJson
Copy
>
LinearMap
<~
str
,
A
>
:
ToJson
{
fn
to_json
()
->
Json
{
let
mut
d
=
linear
::
LinearMap
();
let
mut
d
=
LinearMap
::
new
();
for
self
.each
()
|
key
,
value
|
{
d
.insert
(
copy
*
key
,
value
.to_json
());
}
...
...
@@ -1188,7 +1188,7 @@ fn to_json() -> Json {
/*
impl <A: ToJson Copy> @std::map::HashMap<~str, A>: ToJson {
fn to_json() -> Json {
let mut d =
linear::LinearMap
();
let mut d =
LinearMap::new
();
for self.each_ref |key, value| {
d.insert(copy *key, value.to_json());
}
...
...
@@ -1223,10 +1223,10 @@ mod tests {
use
json
::
*
;
use
core
::
result
;
use
core
::
hashmap
::
linear
;
use
core
::
hashmap
::
linear
::
LinearMap
;
fn
mk_object
(
items
:
&
[(
~
str
,
Json
)])
->
Json
{
let
mut
d
=
~
linear
::
LinearMap
();
let
mut
d
=
LinearMap
::
new
();
for
items
.each
|
item
|
{
match
*
item
{
...
...
src/libstd/net_url.rs
浏览文件 @
7f0fa143
...
...
@@ -242,7 +242,7 @@ pub fn encode_form_urlencoded(m: &LinearMap<~str, ~[~str]>) -> ~str {
*/
pub
fn
decode_form_urlencoded
(
s
:
&
[
u8
])
->
LinearMap
<~
str
,
~
[
~
str
]
>
{
do
io
::
with_bytes_reader
(
s
)
|
rdr
|
{
let
mut
m
=
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
let
mut
key
=
~
""
;
let
mut
value
=
~
""
;
let
mut
parsing_key
=
true
;
...
...
@@ -1053,18 +1053,18 @@ fn test_decode_component() {
#[test]
fn
test_encode_form_urlencoded
()
{
let
mut
m
=
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
assert
encode_form_urlencoded
(
&
m
)
==
~
""
;
m
.insert
(
~
""
,
~
[]);
m
.insert
(
~
"foo"
,
~
[]);
assert
encode_form_urlencoded
(
&
m
)
==
~
""
;
let
mut
m
=
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
m
.insert
(
~
"foo"
,
~
[
~
"bar"
,
~
"123"
]);
assert
encode_form_urlencoded
(
&
m
)
==
~
"foo=bar&foo=123"
;
let
mut
m
=
LinearMap
();
let
mut
m
=
LinearMap
::
new
();
m
.insert
(
~
"foo bar"
,
~
[
~
"abc"
,
~
"12 = 34"
]);
assert
encode_form_urlencoded
(
&
m
)
==
~
"foo+bar=abc&foo+bar=12+%3D+34"
;
}
...
...
src/libstd/workcache.rs
浏览文件 @
7f0fa143
...
...
@@ -152,7 +152,7 @@ fn encode(&self, s: &S) {
pub
impl
<
D
:
Decoder
>
WorkMap
:
Decodable
<
D
>
{
static
fn
decode
(
&
self
,
d
:
&
D
)
->
WorkMap
{
let
v
:
~
[(
WorkKey
,
~
str
)]
=
Decodable
::
decode
(
d
);
let
mut
w
=
LinearMap
();
let
mut
w
=
LinearMap
::
new
();
for
v
.each
|
&
(
k
,
v
)|
{
w
.insert
(
copy
k
,
copy
v
);
}
...
...
@@ -348,8 +348,8 @@ fn exec<T:Owned
let
blk
=
blk
.unwrap
();
let
chan
=
~
mut
Some
(
move
chan
);
do
task
::
spawn
|
move
blk
,
move
chan
|
{
let
exe
=
Exec
{
discovered_inputs
:
LinearMap
(),
discovered_outputs
:
LinearMap
()
};
let
exe
=
Exec
{
discovered_inputs
:
LinearMap
::
new
(),
discovered_outputs
:
LinearMap
::
new
()
};
let
chan
=
option
::
swap_unwrap
(
&
mut
*
chan
);
let
v
=
blk
(
&
exe
);
send_one
(
move
chan
,
(
move
exe
,
move
v
));
...
...
@@ -411,10 +411,10 @@ fn test() {
use
io
::
WriterUtil
;
let
db
=
@
Mut
(
Database
{
db_filename
:
Path
(
"db.json"
),
db_cache
:
LinearMap
(),
db_cache
:
LinearMap
::
new
(),
db_dirty
:
false
});
let
lg
=
@
Mut
(
Logger
{
a
:
()
});
let
cfg
=
@
LinearMap
();
let
cfg
=
@
LinearMap
::
new
();
let
cx
=
@
Context
::
new
(
db
,
lg
,
cfg
);
let
w
:
Work
<~
str
>
=
do
cx
.prep
(
"test1"
)
|
prep
|
{
let
pth
=
Path
(
"foo.c"
);
...
...
src/test/bench/core-map.rs
浏览文件 @
7f0fa143
...
...
@@ -178,10 +178,10 @@ fn main() {
let
rng
=
rand
::
seeded_rng
(
&
seed
);
let
mut
results
=
empty_results
();
int_benchmarks
::
<@
Mut
<
LinearMap
<
uint
,
uint
>>>
(
||
@
Mut
(
LinearMap
()),
||
@
Mut
(
LinearMap
::
new
()),
rng
,
num_keys
,
&
mut
results
);
str_benchmarks
::
<@
Mut
<
LinearMap
<~
str
,
uint
>>>
(
||
@
Mut
(
LinearMap
()),
||
@
Mut
(
LinearMap
::
new
()),
rng
,
num_keys
,
&
mut
results
);
write_results
(
"libstd::map::hashmap"
,
&
results
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录