Skip to content

Commit a202dcc

Browse files
committed
Merge pull request #4594 from thestinger/map
more work on the map trait and TreeMap/LinearMap
2 parents 0e29e21 + bba5520 commit a202dcc

File tree

16 files changed

+327
-295
lines changed

16 files changed

+327
-295
lines changed

src/libcargo/cargo.rc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use core::*;
5252
use core::dvec::DVec;
5353
use core::io::WriterUtil;
5454
use core::result::{Ok, Err};
55-
use core::send_map::linear::LinearMap;
55+
use core::hashmap::linear::LinearMap;
5656
use std::getopts::{optflag, optopt, opt_present};
5757
use std::map::HashMap;
5858
use std::{map, json, tempfile, term, sort, getopts};
@@ -465,19 +465,19 @@ fn parse_source(name: ~str, j: &json::Json) -> @Source {
465465

466466
match *j {
467467
json::Object(j) => {
468-
let mut url = match j.find(&~"url") {
468+
let mut url = match j.find_copy(&~"url") {
469469
Some(json::String(u)) => u,
470470
_ => fail ~"needed 'url' field in source"
471471
};
472-
let method = match j.find(&~"method") {
472+
let method = match j.find_copy(&~"method") {
473473
Some(json::String(u)) => u,
474474
_ => assume_source_method(url)
475475
};
476-
let key = match j.find(&~"key") {
476+
let key = match j.find_copy(&~"key") {
477477
Some(json::String(u)) => Some(u),
478478
_ => None
479479
};
480-
let keyfp = match j.find(&~"keyfp") {
480+
let keyfp = match j.find_copy(&~"keyfp") {
481481
Some(json::String(u)) => Some(u),
482482
_ => None
483483
};
@@ -512,7 +512,7 @@ fn try_parse_sources(filename: &Path, sources: map::HashMap<~str, @Source>) {
512512
}
513513

514514
fn load_one_source_package(src: @Source, p: &json::Object) {
515-
let name = match p.find(&~"name") {
515+
let name = match p.find_copy(&~"name") {
516516
Some(json::String(n)) => {
517517
if !valid_pkg_name(n) {
518518
warn(~"malformed source json: "
@@ -529,7 +529,7 @@ fn load_one_source_package(src: @Source, p: &json::Object) {
529529
}
530530
};
531531

532-
let uuid = match p.find(&~"uuid") {
532+
let uuid = match p.find_copy(&~"uuid") {
533533
Some(json::String(n)) => {
534534
if !is_uuid(n) {
535535
warn(~"malformed source json: "
@@ -545,15 +545,15 @@ fn load_one_source_package(src: @Source, p: &json::Object) {
545545
}
546546
};
547547

548-
let url = match p.find(&~"url") {
548+
let url = match p.find_copy(&~"url") {
549549
Some(json::String(n)) => n,
550550
_ => {
551551
warn(~"malformed source json: " + src.name + ~" (missing url)");
552552
return;
553553
}
554554
};
555555

556-
let method = match p.find(&~"method") {
556+
let method = match p.find_copy(&~"method") {
557557
Some(json::String(n)) => n,
558558
_ => {
559559
warn(~"malformed source json: "
@@ -562,13 +562,13 @@ fn load_one_source_package(src: @Source, p: &json::Object) {
562562
}
563563
};
564564

565-
let reference = match p.find(&~"ref") {
565+
let reference = match p.find_copy(&~"ref") {
566566
Some(json::String(n)) => Some(n),
567567
_ => None
568568
};
569569

570570
let mut tags = ~[];
571-
match p.find(&~"tags") {
571+
match p.find_copy(&~"tags") {
572572
Some(json::List(js)) => {
573573
for js.each |j| {
574574
match *j {
@@ -580,7 +580,7 @@ fn load_one_source_package(src: @Source, p: &json::Object) {
580580
_ => ()
581581
}
582582

583-
let description = match p.find(&~"description") {
583+
let description = match p.find_copy(&~"description") {
584584
Some(json::String(n)) => n,
585585
_ => {
586586
warn(~"malformed source json: " + src.name
@@ -1619,7 +1619,7 @@ fn dump_cache(c: &Cargo) {
16191619
need_dir(&c.root);
16201620

16211621
let out = c.root.push("cache.json");
1622-
let _root = json::Object(~LinearMap());
1622+
let _root = json::Object(~LinearMap::new());
16231623

16241624
if os::path_exists(&out) {
16251625
copy_warn(&out, &c.root.push("cache.json.old"));
@@ -1640,10 +1640,10 @@ fn dump_sources(c: &Cargo) {
16401640

16411641
match io::buffered_file_writer(&out) {
16421642
result::Ok(writer) => {
1643-
let mut hash = ~LinearMap();
1643+
let mut hash = ~LinearMap::new();
16441644

16451645
for c.sources.each |k, v| {
1646-
let mut chash = ~LinearMap();
1646+
let mut chash = ~LinearMap::new();
16471647

16481648
chash.insert(~"url", json::String(v.url));
16491649
chash.insert(~"method", json::String(v.method));

src/libcore/container.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#[forbid(deprecated_mode)];
1414
#[forbid(deprecated_pattern)];
1515

16+
use option::Option;
17+
1618
pub trait Container {
1719
/// Return the number of elements in the container
1820
pure fn len(&self) -> uint;
@@ -39,6 +41,9 @@ pub trait Map<K, V>: Mutable {
3941
/// Visit all values
4042
pure fn each_value(&self, f: fn(&V) -> bool);
4143

44+
/// Return the value corresponding to the key in the map
45+
pure fn find(&self, key: &K) -> Option<&self/V>;
46+
4247
/// Insert a key-value pair into the map. An existing value for a
4348
/// key is replaced by the new value. Return true if the key did
4449
/// not already exist in the map.

src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub mod dvec_iter;
138138
pub mod dlist;
139139
#[path="iter-trait.rs"] #[merge = "iter-trait/dlist.rs"]
140140
pub mod dlist_iter;
141-
pub mod send_map;
141+
pub mod hashmap;
142142

143143

144144
/* Tasks and communication */

src/libcore/gc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use io;
4444
use libc::{size_t, uintptr_t};
4545
use option::{None, Option, Some};
4646
use ptr;
47-
use send_map::linear::LinearSet;
47+
use hashmap::linear::LinearSet;
4848
use stackwalk;
4949
use sys;
5050

0 commit comments

Comments
 (0)