switch LinearMap to current constructor convention

This commit is contained in:
Daniel Micay 2013-01-23 17:06:32 -05:00
parent 591eefd740
commit 7f0fa143bc
6 changed files with 37 additions and 33 deletions

View file

@ -24,7 +24,7 @@ use core::float;
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 @@ priv impl Parser {
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 @@ impl <A: ToJson Copy> linear::LinearMap<~str, A>: ToJson {
/*
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 {

View file

@ -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 @@ mod tests {
#[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";
}

View file

@ -152,7 +152,7 @@ pub impl<S: Encoder> WorkMap: Encodable<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 @@ impl @Mut<Prep> : TPrep {
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");