Skip to content

Commit 1ffd90e

Browse files
committed
Remove redundant hashmap constructor functions.
1 parent 384906c commit 1ffd90e

Some content is hidden

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

53 files changed

+155
-219
lines changed

src/cargo/cargo.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,11 +668,11 @@ fn configure(opts: options) -> cargo {
668668

669669
let p = result::get(get_cargo_dir());
670670

671-
let sources = map::str_hash();
671+
let sources = map::HashMap();
672672
try_parse_sources(&home.push("sources.json"), sources);
673673
try_parse_sources(&home.push("local-sources.json"), sources);
674674

675-
let dep_cache = map::str_hash();
675+
let dep_cache = map::HashMap();
676676

677677
let mut c = {
678678
pgp: pgp::supported(),
@@ -1577,7 +1577,7 @@ fn dump_cache(c: &cargo) {
15771577
need_dir(&c.root);
15781578

15791579
let out = c.root.push("cache.json");
1580-
let _root = json::Dict(map::str_hash());
1580+
let _root = json::Dict(map::HashMap());
15811581

15821582
if os::path_exists(&out) {
15831583
copy_warn(&out, &c.root.push("cache.json.old"));
@@ -1598,11 +1598,11 @@ fn dump_sources(c: &cargo) {
15981598

15991599
match io::buffered_file_writer(&out) {
16001600
result::Ok(writer) => {
1601-
let hash = map::str_hash();
1601+
let hash = map::HashMap();
16021602
let root = json::Dict(hash);
16031603

16041604
for c.sources.each |k, v| {
1605-
let chash = map::str_hash();
1605+
let chash = map::HashMap();
16061606
let child = json::Dict(chash);
16071607

16081608
chash.insert(~"url", json::String(@v.url));

src/libstd/json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl Parser {
517517
self.bump();
518518
self.parse_whitespace();
519519

520-
let values = map::str_hash();
520+
let values = map::HashMap();
521521

522522
if self.ch == '}' {
523523
self.bump();
@@ -802,7 +802,7 @@ impl <A: ToJson> ~[A]: ToJson {
802802

803803
impl <A: ToJson Copy> HashMap<~str, A>: ToJson {
804804
fn to_json() -> Json {
805-
let d = map::str_hash();
805+
let d = map::HashMap();
806806
for self.each() |key, value| {
807807
d.insert(copy key, value.to_json());
808808
}
@@ -832,7 +832,7 @@ impl Error: to_str::ToStr {
832832
#[cfg(test)]
833833
mod tests {
834834
fn mk_dict(items: &[(~str, Json)]) -> Json {
835-
let d = map::str_hash();
835+
let d = map::HashMap();
836836

837837
for vec::each(items) |item| {
838838
let (key, value) = copy *item;

src/libstd/map.rs

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ use core::cmp::Eq;
1212
use hash::Hash;
1313
use to_bytes::IterBytes;
1414

15-
export HashMap, hashfn, eqfn, Set, Map, chained, hashmap, str_hash;
16-
export box_str_hash;
17-
export bytes_hash, int_hash, uint_hash, set_add;
18-
export hash_from_vec, hash_from_strs, hash_from_bytes;
19-
export hash_from_ints, hash_from_uints;
15+
export HashMap, hashfn, eqfn, Set, Map, chained, set_add;
16+
export hash_from_vec;
2017
export vec_from_set;
2118

2219
/// A convenience type to treat a hashmap as a set
@@ -385,36 +382,6 @@ fn HashMap<K:Eq IterBytes Hash Const, V: Copy>()
385382
chained::mk()
386383
}
387384

388-
/// Construct a hashmap for string-slice keys
389-
fn str_slice_hash<V: Copy>() -> HashMap<&str, V> {
390-
return HashMap();
391-
}
392-
393-
/// Construct a hashmap for string keys
394-
fn str_hash<V: Copy>() -> HashMap<~str, V> {
395-
return HashMap();
396-
}
397-
398-
/// Construct a hashmap for boxed string keys
399-
fn box_str_hash<V: Copy>() -> HashMap<@~str, V> {
400-
HashMap()
401-
}
402-
403-
/// Construct a hashmap for byte string keys
404-
fn bytes_hash<V: Copy>() -> HashMap<~[u8], V> {
405-
return HashMap();
406-
}
407-
408-
/// Construct a hashmap for int keys
409-
fn int_hash<V: Copy>() -> HashMap<int, V> {
410-
return HashMap();
411-
}
412-
413-
/// Construct a hashmap for uint keys
414-
fn uint_hash<V: Copy>() -> HashMap<uint, V> {
415-
return HashMap();
416-
}
417-
418385
/// Convenience function for adding keys to a hashmap with nil type keys
419386
fn set_add<K:Eq IterBytes Hash Const Copy>(set: Set<K>, +key: K) -> bool {
420387
set.insert(key, ())
@@ -445,26 +412,6 @@ fn hash_from_vec<K: Eq IterBytes Hash Const Copy, V: Copy>(
445412
map
446413
}
447414

448-
/// Construct a hashmap from a vector with string keys
449-
fn hash_from_strs<V: Copy>(items: &[(~str, V)]) -> HashMap<~str, V> {
450-
hash_from_vec(items)
451-
}
452-
453-
/// Construct a hashmap from a vector with byte keys
454-
fn hash_from_bytes<V: Copy>(items: &[(~[u8], V)]) -> HashMap<~[u8], V> {
455-
hash_from_vec(items)
456-
}
457-
458-
/// Construct a hashmap from a vector with int keys
459-
fn hash_from_ints<V: Copy>(items: &[(int, V)]) -> HashMap<int, V> {
460-
hash_from_vec(items)
461-
}
462-
463-
/// Construct a hashmap from a vector with uint keys
464-
fn hash_from_uints<V: Copy>(items: &[(uint, V)]) -> HashMap<uint, V> {
465-
hash_from_vec(items)
466-
}
467-
468415
// XXX Transitional
469416
impl<K: Eq IterBytes Hash Copy, V: Copy> @Mut<LinearMap<K, V>>:
470417
Map<K, V> {
@@ -810,7 +757,7 @@ mod tests {
810757

811758
#[test]
812759
fn test_hash_from_vec() {
813-
let map = map::hash_from_strs(~[
760+
let map = map::hash_from_vec(~[
814761
(~"a", 1),
815762
(~"b", 2),
816763
(~"c", 3)

src/libstd/net_url.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#[forbid(deprecated_pattern)];
44

55
use core::cmp::Eq;
6-
use map::{HashMap, str_hash};
6+
use map::HashMap;
77
use io::{Reader, ReaderUtil};
88
use dvec::DVec;
99
use from_str::FromStr;
@@ -213,7 +213,7 @@ fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str {
213213
fn decode_form_urlencoded(s: ~[u8]) ->
214214
map::HashMap<~str, @dvec::DVec<@~str>> {
215215
do io::with_bytes_reader(s) |rdr| {
216-
let m = str_hash();
216+
let m = HashMap();
217217
let mut key = ~"";
218218
let mut value = ~"";
219219
let mut parsing_key = true;
@@ -1069,26 +1069,24 @@ mod tests {
10691069

10701070
#[test]
10711071
fn test_encode_form_urlencoded() {
1072-
let m = str_hash();
1072+
let m = HashMap();
10731073
assert encode_form_urlencoded(m) == ~"";
10741074

10751075
m.insert(~"", @DVec());
10761076
m.insert(~"foo", @DVec());
10771077
assert encode_form_urlencoded(m) == ~"";
10781078

1079-
let m = str_hash();
1079+
let m = HashMap();
10801080
m.insert(~"foo", @dvec::from_vec(~[@~"bar", @~"123"]));
10811081
assert encode_form_urlencoded(m) == ~"foo=bar&foo=123";
10821082

1083-
let m = str_hash();
1083+
let m = HashMap();
10841084
m.insert(~"foo bar", @dvec::from_vec(~[@~"abc", @~"12 = 34"]));
10851085
assert encode_form_urlencoded(m) == ~"foo+bar=abc&foo+bar=12+%3D+34";
10861086
}
10871087

10881088
#[test]
10891089
fn test_decode_form_urlencoded() {
1090-
use map::hash_from_strs;
1091-
10921090
assert decode_form_urlencoded(~[]).size() == 0;
10931091

10941092
let s = str::to_bytes(~"a=1&foo+bar=abc&foo+bar=12+%3D+34");

src/libsyntax/ast_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn mk_ast_map_visitor() -> vt {
103103
}
104104

105105
fn map_crate(diag: span_handler, c: crate) -> map {
106-
let cx = {map: std::map::int_hash(),
106+
let cx = {map: std::map::HashMap(),
107107
mut path: ~[],
108108
mut local_id: 0u,
109109
diag: diag};

src/libsyntax/ast_util.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,6 @@ impl def_id : core::to_bytes::IterBytes {
259259
}
260260
}
261261

262-
fn new_def_hash<V: Copy>() -> std::map::HashMap<ast::def_id, V> {
263-
return std::map::HashMap::<ast::def_id, V>();
264-
}
265-
266262
fn block_from_expr(e: @expr) -> blk {
267263
let blk_ = default_block(~[], option::Some::<@expr>(e), e.id);
268264
return {node: blk_, span: e.span};

src/libsyntax/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr {
368368

369369
fn require_unique_names(diagnostic: span_handler,
370370
metas: ~[@ast::meta_item]) {
371-
let map = map::str_hash();
371+
let map = map::HashMap();
372372
for metas.each |meta| {
373373
let name = get_meta_item_name(meta);
374374

src/libsyntax/ext/auto_serialize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
564564
id: cx.next_id()}],
565565
tp_inputs);
566566

567-
let tps_map = map::uint_hash();
567+
let tps_map = map::HashMap();
568568
do vec::iter2(tps, tp_inputs) |tp, arg| {
569569
let arg_ident = arg.ident;
570570
tps_map.insert(
@@ -771,7 +771,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span,
771771
id: cx.next_id()}],
772772
tp_inputs);
773773

774-
let tps_map = map::uint_hash();
774+
let tps_map = map::HashMap();
775775
do vec::iter2(tps, tp_inputs) |tp, arg| {
776776
let arg_ident = arg.ident;
777777
tps_map.insert(

src/libsyntax/ext/base.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::map::HashMap;
22
use parse::parser;
33
use diagnostic::span_handler;
44
use codemap::{codemap, span, expn_info, expanded_from};
5-
use std::map::str_hash;
65

76
// obsolete old-style #macro code:
87
//
@@ -74,7 +73,7 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
7473
fn builtin_item_tt(f: syntax_expander_tt_item_) -> syntax_extension {
7574
item_tt({expander: f, span: None})
7675
}
77-
let syntax_expanders = str_hash::<syntax_extension>();
76+
let syntax_expanders = HashMap::<~str,syntax_extension>();
7877
syntax_expanders.insert(~"macro",
7978
macro_defining(ext::simplext::add_new_extension));
8079
syntax_expanders.insert(~"macro_rules",

src/libsyntax/ext/simplext.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use codemap::span;
2-
use std::map::{HashMap, str_hash, uint_hash};
2+
use std::map::HashMap;
33
use dvec::DVec;
44

55
use base::*;
@@ -135,7 +135,7 @@ fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }
135135

136136
fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders {
137137
let res: binders =
138-
{real_binders: uint_hash::<selector>(),
138+
{real_binders: HashMap(),
139139
literal_ast_matchers: DVec()};
140140
//this oughta return binders instead, but macro args are a sequence of
141141
//expressions, rather than a single expression
@@ -153,7 +153,7 @@ bindings. Most of the work is done in p_t_s, which generates the
153153
selectors. */
154154

155155
fn use_selectors_to_bind(b: binders, e: @expr) -> Option<bindings> {
156-
let res = uint_hash::<arb_depth<matchable>>();
156+
let res = HashMap();
157157
//need to do this first, to check vec lengths.
158158
for b.literal_ast_matchers.each |sel| {
159159
match sel(match_expr(e)) { None => return None, _ => () }
@@ -237,7 +237,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: Option<arb_depth<matchable>>,
237237

238238
/* helper for transcribe_exprs: what vars from `b` occur in `e`? */
239239
fn free_vars(b: bindings, e: @expr, it: fn(ident)) {
240-
let idents: HashMap<ident, ()> = uint_hash::<()>();
240+
let idents: HashMap<ident, ()> = HashMap();
241241
fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings,
242242
idents: HashMap<ident, ()>) -> ident {
243243
if b.contains_key(i) { idents.insert(i, ()); }

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use parse::parse_sess;
1010
use dvec::DVec;
1111
use ast::{matcher, match_tok, match_seq, match_nonterminal, ident};
1212
use ast_util::mk_sp;
13-
use std::map::{HashMap, uint_hash};
13+
use std::map::HashMap;
1414

1515
/* This is an Earley-like parser, without support for in-grammar nonterminals,
1616
only by calling out to the main rust parser for named nonterminals (which it
@@ -185,7 +185,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match])
185185
}
186186
}
187187
}
188-
let ret_val = uint_hash::<@named_match>();
188+
let ret_val = HashMap::<uint,@named_match>();
189189
for ms.each() |m| { n_rec(p_s, m, res, ret_val) }
190190
return ret_val;
191191
}

src/libsyntax/ext/tt/transcribe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use macro_parser::{named_match, matched_seq, matched_nonterminal};
44
use codemap::span;
55
use parse::token::{EOF, INTERPOLATED, IDENT, token, nt_ident,
66
ident_interner};
7-
use std::map::{HashMap, box_str_hash};
7+
use std::map::HashMap;
88

99
export tt_reader, new_tt_reader, dup_tt_reader, tt_next_token;
1010

@@ -47,7 +47,7 @@ fn new_tt_reader(sp_diag: span_handler, itr: ident_interner,
4747
mut cur: @{readme: src, mut idx: 0u, dotdotdoted: false,
4848
sep: None, up: tt_frame_up(option::None)},
4949
interpolations: match interp { /* just a convienience */
50-
None => std::map::uint_hash::<@named_match>(),
50+
None => std::map::HashMap::<uint,@named_match>(),
5151
Some(x) => x
5252
},
5353
mut repeat_idx: ~[mut], mut repeat_len: ~[],

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use print::pprust::expr_to_str;
22

33
use result::Result;
44
use either::{Either, Left, Right};
5-
use std::map::{HashMap, str_hash};
5+
use std::map::HashMap;
66
use token::{can_begin_expr, is_ident, is_ident_or_path, is_plain_ident,
77
INTERPOLATED, special_idents};
88
use codemap::{span,fss_none};

src/libsyntax/parse/token.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use util::interner;
22
use util::interner::interner;
3-
use std::map::{HashMap, str_hash};
3+
use std::map::HashMap;
44
use std::serialization::{Serializer,
55
Deserializer,
66
serialize_uint,
@@ -369,7 +369,7 @@ fn mk_fake_ident_interner() -> ident_interner {
369369
* the language and may not appear as identifiers.
370370
*/
371371
fn keyword_table() -> HashMap<~str, ()> {
372-
let keywords = str_hash();
372+
let keywords = HashMap();
373373
for temporary_keyword_table().each_key |word| {
374374
keywords.insert(word, ());
375375
}
@@ -384,7 +384,7 @@ fn keyword_table() -> HashMap<~str, ()> {
384384

385385
/// Keywords that may be used as identifiers
386386
fn temporary_keyword_table() -> HashMap<~str, ()> {
387-
let words = str_hash();
387+
let words = HashMap();
388388
let keys = ~[
389389
~"self", ~"static",
390390
];
@@ -396,7 +396,7 @@ fn temporary_keyword_table() -> HashMap<~str, ()> {
396396

397397
/// Full keywords. May not appear anywhere else.
398398
fn strict_keyword_table() -> HashMap<~str, ()> {
399-
let words = str_hash();
399+
let words = HashMap();
400400
let keys = ~[
401401
~"as", ~"assert",
402402
~"break",
@@ -421,7 +421,7 @@ fn strict_keyword_table() -> HashMap<~str, ()> {
421421
}
422422
423423
fn reserved_keyword_table() -> HashMap<~str, ()> {
424-
let words = str_hash();
424+
let words = HashMap();
425425
let keys = ~[
426426
~"be"
427427
];

src/rustc/back/rpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn get_install_prefix_rpath(target_triple: &str) -> Path {
167167
}
168168

169169
fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] {
170-
let set = map::str_hash::<()>();
170+
let set = map::HashMap();
171171
let mut minimized = ~[];
172172
for rpaths.each |rpath| {
173173
let s = rpath.to_str();

0 commit comments

Comments
 (0)