Skip to content

Commit 736155e

Browse files
committed
libstd: Change HashMap::new and HashSet::new to HashMap::init and
`HashSet::init` respectively
1 parent cf3f0bd commit 736155e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+275
-275
lines changed

src/libextra/stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ pub fn write_boxplot(w: &mut io::Writer, s: &Summary, width_hint: uint) {
372372
/// Returns a HashMap with the number of occurrences of every element in the
373373
/// sequence that the iterator exposes.
374374
pub fn freq_count<T: Iterator<U>, U: Eq+Hash>(mut iter: T) -> hashmap::HashMap<U, uint> {
375-
let mut map: hashmap::HashMap<U,uint> = hashmap::HashMap::new();
375+
let mut map: hashmap::HashMap<U,uint> = hashmap::HashMap::init();
376376
for elem in iter {
377377
map.insert_or_update_with(elem, 1, |_, count| *count += 1);
378378
}

src/libextra/terminfo/parser/compiled.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub fn parse(file: &mut io::Reader,
222222

223223
debug!("term names: {:?}", term_names);
224224

225-
let mut bools_map = HashMap::new();
225+
let mut bools_map = HashMap::init();
226226
if bools_bytes != 0 {
227227
for i in range(0, bools_bytes) {
228228
let b = file.read_byte().unwrap();
@@ -243,7 +243,7 @@ pub fn parse(file: &mut io::Reader,
243243
file.read_byte(); // compensate for padding
244244
}
245245

246-
let mut numbers_map = HashMap::new();
246+
let mut numbers_map = HashMap::init();
247247
if numbers_count != 0 {
248248
for i in range(0, numbers_count) {
249249
let n = file.read_le_u16();
@@ -256,7 +256,7 @@ pub fn parse(file: &mut io::Reader,
256256

257257
debug!("numbers: {:?}", numbers_map);
258258

259-
let mut string_map = HashMap::new();
259+
let mut string_map = HashMap::init();
260260

261261
if string_offsets_count != 0 {
262262
let mut string_offsets = vec::with_capacity(10);

src/libextra/url.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub fn encode_form_urlencoded(m: &HashMap<~str, ~[~str]>) -> ~str {
245245
*/
246246
pub fn decode_form_urlencoded(s: &[u8]) -> HashMap<~str, ~[~str]> {
247247
let mut rdr = BufReader::new(s);
248-
let mut m = HashMap::new();
248+
let mut m = HashMap::init();
249249
let mut key = ~"";
250250
let mut value = ~"";
251251
let mut parsing_key = true;
@@ -1086,18 +1086,18 @@ mod tests {
10861086
10871087
#[test]
10881088
fn test_encode_form_urlencoded() {
1089-
let mut m = HashMap::new();
1089+
let mut m = HashMap::init();
10901090
assert_eq!(encode_form_urlencoded(&m), ~"");
10911091
10921092
m.insert(~"", ~[]);
10931093
m.insert(~"foo", ~[]);
10941094
assert_eq!(encode_form_urlencoded(&m), ~"");
10951095
1096-
let mut m = HashMap::new();
1096+
let mut m = HashMap::init();
10971097
m.insert(~"foo", ~[~"bar", ~"123"]);
10981098
assert_eq!(encode_form_urlencoded(&m), ~"foo=bar&foo=123");
10991099
1100-
let mut m = HashMap::new();
1100+
let mut m = HashMap::init();
11011101
m.insert(~"foo bar", ~[~"abc", ~"12 = 34"]);
11021102
assert!(encode_form_urlencoded(&m) ==
11031103
~"foo+bar=abc&foo+bar=12+%3D+34");

src/librustc/back/rpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> ~str {
156156
}
157157

158158
pub fn minimize_rpaths(rpaths: &[~str]) -> ~[~str] {
159-
let mut set = HashSet::new();
159+
let mut set = HashSet::init();
160160
let mut minimized = ~[];
161161
for rpath in rpaths.iter() {
162162
if set.insert(rpath.as_slice()) {

src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ pub fn build_session_(sopts: @session::options,
843843
filesearch: filesearch,
844844
building_library: @mut false,
845845
working_dir: os::getcwd(),
846-
lints: @mut HashMap::new(),
846+
lints: @mut HashMap::init(),
847847
node_id: @mut 1
848848
}
849849
}

src/librustc/driver/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ pub fn basic_options() -> @options {
368368
save_temps: false,
369369
jit: false,
370370
output_type: link::output_type_exe,
371-
addl_lib_search_paths: @mut HashSet::new(),
371+
addl_lib_search_paths: @mut HashSet::init(),
372372
linker: None,
373373
linker_args: ~[],
374374
maybe_sysroot: None,

src/librustc/lib/llvm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,8 @@ pub struct TypeNames {
17751775
impl TypeNames {
17761776
pub fn new() -> TypeNames {
17771777
TypeNames {
1778-
type_names: HashMap::new(),
1779-
named_types: HashMap::new()
1778+
type_names: HashMap::init(),
1779+
named_types: HashMap::init()
17801780
}
17811781
}
17821782

src/librustc/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ fn resolve_crate_deps(e: @mut Env, cdata: @~[u8]) -> cstore::cnum_map {
324324
debug!("resolving deps of external crate");
325325
// The map from crate numbers in the crate we're resolving to local crate
326326
// numbers
327-
let mut cnum_map = HashMap::new();
327+
let mut cnum_map = HashMap::init();
328328
let r = decoder::get_crate_deps(cdata);
329329
for dep in r.iter() {
330330
let extrn_cnum = dep.cnum;

src/librustc/metadata/cstore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ type extern_mod_crate_map = HashMap<ast::NodeId, ast::CrateNum>;
4848

4949
pub fn mk_cstore(intr: @ident_interner) -> CStore {
5050
return CStore {
51-
metas: HashMap::new(),
52-
extern_mod_crate_map: HashMap::new(),
51+
metas: HashMap::init(),
52+
extern_mod_crate_map: HashMap::init(),
5353
used_crate_files: ~[],
5454
used_libraries: ~[],
5555
used_link_args: ~[],

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
17711771
non_inlineable_statics,
17721772
_
17731773
} = parms;
1774-
let type_abbrevs = @mut HashMap::new();
1774+
let type_abbrevs = @mut HashMap::init();
17751775
let stats = @mut stats;
17761776
let ecx = EncodeContext {
17771777
diag: diag,

src/librustc/metadata/filesearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
5353
fn sysroot(&self) -> @Path { self.sysroot }
5454

5555
fn for_each_lib_search_path(&self, f: |&Path| -> FileMatch) {
56-
let mut visited_dirs = HashSet::new();
56+
let mut visited_dirs = HashSet::init();
5757
let mut found = false;
5858

5959
debug!("filesearch: searching additional lib search paths [{:?}]",

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn check_loans(bccx: &BorrowckCtxt,
7272
dfcx_loans: dfcx_loans,
7373
move_data: @move_data,
7474
all_loans: all_loans,
75-
reported: @mut HashSet::new(),
75+
reported: @mut HashSet::init(),
7676
};
7777

7878
clcx.visit_block(body, ());

src/librustc/middle/borrowck/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ pub fn check_crate(
8282
moved_variables_set: moved_variables_set,
8383
capture_map: capture_map,
8484
root_map: root_map(),
85-
loan_map: @mut HashMap::new(),
86-
write_guard_map: @mut HashSet::new(),
87-
stmt_map: @mut HashSet::new(),
85+
loan_map: @mut HashMap::init(),
86+
write_guard_map: @mut HashSet::init(),
87+
stmt_map: @mut HashSet::init(),
8888
stats: @mut BorrowStats {
8989
loaned_paths_same: 0,
9090
loaned_paths_imm: 0,
@@ -417,7 +417,7 @@ pub struct RootInfo {
417417
pub type root_map = @mut HashMap<root_map_key, RootInfo>;
418418

419419
pub fn root_map() -> root_map {
420-
return @mut HashMap::new();
420+
return @mut HashMap::init();
421421
}
422422

423423
pub enum DynaFreezeKind {

src/librustc/middle/borrowck/move_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ impl MoveData {
166166
pub fn new() -> MoveData {
167167
MoveData {
168168
paths: ~[],
169-
path_map: HashMap::new(),
169+
path_map: HashMap::init(),
170170
moves: ~[],
171171
path_assignments: ~[],
172172
var_assignments: ~[],
173-
assignee_ids: HashSet::new(),
173+
assignee_ids: HashSet::init(),
174174
}
175175
}
176176

src/librustc/middle/cfg/construct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn construct(tcx: ty::ctxt,
3535
method_map: typeck::method_map,
3636
blk: &ast::Block) -> CFG {
3737
let mut cfg_builder = CFGBuilder {
38-
exit_map: HashMap::new(),
38+
exit_map: HashMap::init(),
3939
graph: graph::Graph::new(),
4040
tcx: tcx,
4141
method_map: method_map,

src/librustc/middle/const_eval.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
116116
None => {}
117117
}
118118
let maps = astencode::Maps {
119-
root_map: @mut HashMap::new(),
120-
method_map: @mut HashMap::new(),
121-
vtable_map: @mut HashMap::new(),
122-
write_guard_map: @mut HashSet::new(),
123-
capture_map: @mut HashMap::new()
119+
root_map: @mut HashMap::init(),
120+
method_map: @mut HashMap::init(),
121+
vtable_map: @mut HashMap::init(),
122+
write_guard_map: @mut HashSet::init(),
123+
capture_map: @mut HashMap::init()
124124
};
125125
let e = match csearch::maybe_get_item_ast(tcx, enum_def,
126126
|a, b, c, d| astencode::decode_inlined_item(a,
@@ -159,11 +159,11 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
159159
None => {}
160160
}
161161
let maps = astencode::Maps {
162-
root_map: @mut HashMap::new(),
163-
method_map: @mut HashMap::new(),
164-
vtable_map: @mut HashMap::new(),
165-
write_guard_map: @mut HashSet::new(),
166-
capture_map: @mut HashMap::new()
162+
root_map: @mut HashMap::init(),
163+
method_map: @mut HashMap::init(),
164+
vtable_map: @mut HashMap::init(),
165+
write_guard_map: @mut HashSet::init(),
166+
capture_map: @mut HashMap::init()
167167
};
168168
let e = match csearch::maybe_get_item_ast(tcx, def_id,
169169
|a, b, c, d| astencode::decode_inlined_item(a, b, maps, c, d)) {
@@ -280,7 +280,7 @@ pub fn process_crate(crate: &ast::Crate,
280280
tcx: ty::ctxt) {
281281
let mut v = ConstEvalVisitor {
282282
tcx: tcx,
283-
ccache: HashMap::new(),
283+
ccache: HashMap::init(),
284284
};
285285
visit::walk_crate(&mut v, crate, ());
286286
tcx.sess.abort_if_errors();

src/librustc/middle/dataflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<O:DataFlowOperator> DataFlowContext<O> {
142142
tcx: tcx,
143143
method_map: method_map,
144144
words_per_id: words_per_id,
145-
nodeid_to_bitset: HashMap::new(),
145+
nodeid_to_bitset: HashMap::init(),
146146
bits_per_id: bits_per_id,
147147
oper: oper,
148148
gens: gens,

src/librustc/middle/freevars.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Visitor<int> for CollectFreevarsVisitor {
9090
// in order to start the search.
9191
fn collect_freevars(def_map: resolve::DefMap, blk: &ast::Block)
9292
-> freevar_info {
93-
let seen = @mut HashMap::new();
93+
let seen = @mut HashMap::init();
9494
let refs = @mut ~[];
9595

9696
let mut v = CollectFreevarsVisitor {
@@ -124,7 +124,7 @@ impl Visitor<()> for AnnotateFreevarsVisitor {
124124
// one pass. This could be improved upon if it turns out to matter.
125125
pub fn annotate_freevars(def_map: resolve::DefMap, crate: &ast::Crate) ->
126126
freevar_map {
127-
let freevars = @mut HashMap::new();
127+
let freevars = @mut HashMap::init();
128128

129129
let mut visitor = AnnotateFreevarsVisitor {
130130
def_map: def_map,

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl<'self> Visitor<()> for LanguageItemVisitor<'self> {
334334

335335
impl LanguageItemCollector {
336336
pub fn new(session: Session) -> LanguageItemCollector {
337-
let mut item_refs = HashMap::new();
337+
let mut item_refs = HashMap::init();
338338

339339
item_refs.insert("freeze", FreezeTraitLangItem as uint);
340340
item_refs.insert("send", SendTraitLangItem as uint);

src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
320320
'-' to '_' in command-line flags
321321
*/
322322
pub fn get_lint_dict() -> LintDict {
323-
let mut map = HashMap::new();
323+
let mut map = HashMap::init();
324324
for &(k, v) in lint_table.iter() {
325325
map.insert(k, v);
326326
}

src/librustc/middle/liveness.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ fn IrMaps(tcx: ty::ctxt,
263263
capture_map: capture_map,
264264
num_live_nodes: 0,
265265
num_vars: 0,
266-
live_node_map: HashMap::new(),
267-
variable_map: HashMap::new(),
268-
capture_info_map: HashMap::new(),
266+
live_node_map: HashMap::init(),
267+
variable_map: HashMap::init(),
268+
capture_info_map: HashMap::init(),
269269
var_kinds: ~[],
270270
lnks: ~[],
271271
}
@@ -603,8 +603,8 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness {
603603
users: @mut vec::from_elem(ir.num_live_nodes * ir.num_vars,
604604
invalid_users()),
605605
loop_scope: @mut ~[],
606-
break_ln: @mut HashMap::new(),
607-
cont_ln: @mut HashMap::new()
606+
break_ln: @mut HashMap::init(),
607+
cont_ln: @mut HashMap::init()
608608
}
609609
}
610610

src/librustc/middle/moves.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ pub fn compute_moves(tcx: ty::ctxt,
212212
tcx: tcx,
213213
method_map: method_map,
214214
move_maps: MoveMaps {
215-
moves_map: @mut HashSet::new(),
216-
capture_map: @mut HashMap::new(),
217-
moved_variables_set: @mut HashSet::new()
215+
moves_map: @mut HashSet::init(),
216+
capture_map: @mut HashMap::init(),
217+
moved_variables_set: @mut HashSet::init()
218218
}
219219
};
220220
let visit_cx = &mut visit_cx;

src/librustc/middle/pat_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub type PatIdMap = HashMap<Ident, NodeId>;
2121
// This is used because same-named variables in alternative patterns need to
2222
// use the NodeId of their namesake in the first pattern.
2323
pub fn pat_id_map(dm: resolve::DefMap, pat: @Pat) -> PatIdMap {
24-
let mut map = HashMap::new();
24+
let mut map = HashMap::init();
2525
pat_bindings(dm, pat, |_bm, p_id, _s, n| {
2626
map.insert(path_to_ident(n), p_id);
2727
});

src/librustc/middle/privacy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,9 @@ pub fn check_crate(tcx: ty::ctxt,
950950
external_exports: resolve::ExternalExports,
951951
last_private_map: resolve::LastPrivateMap,
952952
crate: &ast::Crate) -> ExportedItems {
953-
let mut parents = HashMap::new();
954-
let mut path_all_public_items = HashSet::new();
955-
let mut exported_items = HashSet::new();
953+
let mut parents = HashMap::init();
954+
let mut path_all_public_items = HashSet::init();
955+
let mut exported_items = HashSet::init();
956956

957957
// First, figure out who everyone's parent is
958958
{

src/librustc/middle/reachable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl ReachableContext {
174174
ReachableContext {
175175
tcx: tcx,
176176
method_map: method_map,
177-
reachable_symbols: @mut HashSet::new(),
177+
reachable_symbols: @mut HashSet::init(),
178178
worklist: @mut ~[],
179179
}
180180
}
@@ -253,7 +253,7 @@ impl ReachableContext {
253253
// Step 2: Mark all symbols that the symbols on the worklist touch.
254254
fn propagate(&self) {
255255
let mut visitor = self.init_visitor();
256-
let mut scanned = HashSet::new();
256+
let mut scanned = HashSet::init();
257257
while self.worklist.len() > 0 {
258258
let search_item = self.worklist.pop();
259259
if scanned.contains(&search_item) {

src/librustc/middle/region.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,9 @@ pub fn resolve_crate(sess: Session,
498498
crate: &ast::Crate) -> @mut RegionMaps
499499
{
500500
let region_maps = @mut RegionMaps {
501-
scope_map: HashMap::new(),
502-
free_region_map: HashMap::new(),
503-
cleanup_scopes: HashSet::new(),
501+
scope_map: HashMap::init(),
502+
free_region_map: HashMap::init(),
503+
cleanup_scopes: HashSet::init(),
504504
};
505505
let cx = Context {parent: None,
506506
var_parent: None};

0 commit comments

Comments
 (0)