Skip to content

Commit a239c0e

Browse files
committed
Make addl_lib_search_paths a HashSet (Closes #7718).
1 parent 950add4 commit a239c0e

File tree

9 files changed

+42
-23
lines changed

9 files changed

+42
-23
lines changed

src/librustc/driver/driver.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,9 @@ pub fn build_session_options(binary: @str,
757757

758758
let statik = debugging_opts & session::statik != 0;
759759

760-
let addl_lib_search_paths = matches.opt_strs("L").map(|s| Path::new(s.as_slice()));
760+
let addl_lib_search_paths = matches.opt_strs("L").map(|s| {
761+
Path::new(s.as_slice())
762+
}).move_iter().collect();
761763
let linker = matches.opt_str("linker");
762764
let linker_args = matches.opt_strs("link-args").flat_map( |a| {
763765
a.split_iter(' ').map(|arg| arg.to_owned()).collect()

src/librustc/driver/session.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use syntax::parse::token;
2929
use syntax;
3030

3131
use std::int;
32-
use std::hashmap::HashMap;
32+
use std::hashmap::{HashMap,HashSet};
3333

3434
#[deriving(Eq)]
3535
pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, }
@@ -158,9 +158,9 @@ pub struct options {
158158
save_temps: bool,
159159
jit: bool,
160160
output_type: back::link::output_type,
161-
addl_lib_search_paths: @mut ~[Path], // This is mutable for rustpkg, which
162-
// updates search paths based on the
163-
// parsed code
161+
addl_lib_search_paths: @mut HashSet<Path>, // This is mutable for rustpkg, which
162+
// updates search paths based on the
163+
// parsed code
164164
linker: Option<~str>,
165165
linker_args: ~[~str],
166166
maybe_sysroot: Option<@Path>,
@@ -366,7 +366,7 @@ pub fn basic_options() -> @options {
366366
save_temps: false,
367367
jit: false,
368368
output_type: link::output_type_exe,
369-
addl_lib_search_paths: @mut ~[],
369+
addl_lib_search_paths: @mut HashSet::new(),
370370
linker: None,
371371
linker_args: ~[],
372372
maybe_sysroot: None,

src/librustc/metadata/filesearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ pub trait FileSearch {
4040

4141
pub fn mk_filesearch(maybe_sysroot: &Option<@Path>,
4242
target_triple: &str,
43-
addl_lib_search_paths: @mut ~[Path])
43+
addl_lib_search_paths: @mut HashSet<Path>)
4444
-> @FileSearch {
4545
struct FileSearchImpl {
4646
sysroot: @Path,
47-
addl_lib_search_paths: @mut ~[Path],
47+
addl_lib_search_paths: @mut HashSet<Path>,
4848
target_triple: ~str
4949
}
5050
impl FileSearch for FileSearchImpl {

src/librustdoc/core.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use syntax;
2020

2121
use std::os;
2222
use std::local_data;
23-
use std::hashmap::HashMap;
23+
use std::hashmap::{HashMap,HashSet};
2424

2525
use visit_ast::RustdocVisitor;
2626
use clean;
@@ -39,7 +39,7 @@ pub struct CrateAnalysis {
3939

4040
/// Parses, resolves, and typechecks the given crate
4141
fn get_ast_and_resolve(cpath: &Path,
42-
libs: ~[Path]) -> (DocContext, CrateAnalysis) {
42+
libs: HashSet<Path>) -> (DocContext, CrateAnalysis) {
4343
use syntax::codemap::dummy_spanned;
4444
use rustc::driver::driver::{file_input, build_configuration,
4545
phase_1_parse_input,
@@ -89,7 +89,7 @@ fn get_ast_and_resolve(cpath: &Path,
8989
CrateAnalysis { reexports: reexports, exported_items: exported_items });
9090
}
9191

92-
pub fn run_core (libs: ~[Path], path: &Path) -> (clean::Crate, CrateAnalysis) {
92+
pub fn run_core (libs: HashSet<Path>, path: &Path) -> (clean::Crate, CrateAnalysis) {
9393
let (ctxt, analysis) = get_ast_and_resolve(path, libs);
9494
let ctxt = @ctxt;
9595
debug!("defmap:");

src/librustdoc/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
198198
info!("starting to run rustc");
199199
let (crate, analysis) = do std::task::try {
200200
let cr = cr.take();
201-
core::run_core(libs.take(), &cr)
201+
core::run_core(libs.take().move_iter().collect(), &cr)
202202
}.unwrap();
203203
info!("finished with rustc");
204204
local_data::set(analysiskey, analysis);

src/librustpkg/context.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010

1111
// Context data structure used by rustpkg
1212

13-
use std::os;
1413
use extra::workcache;
1514
use rustc::driver::session::{OptLevel, No};
1615

16+
use std::hashmap::HashSet;
17+
use std::os;
18+
1719
#[deriving(Clone)]
1820
pub struct Context {
1921
// Config strings that the user passed in with --cfg
@@ -60,7 +62,7 @@ impl BuildContext {
6062
self.context.add_library_path(p);
6163
}
6264

63-
pub fn additional_library_paths(&self) -> ~[Path] {
65+
pub fn additional_library_paths(&self) -> HashSet<Path> {
6466
self.context.rustc_flags.additional_library_paths.clone()
6567
}
6668
}
@@ -96,7 +98,7 @@ pub struct RustcFlags {
9698
target_cpu: Option<~str>,
9799
// Additional library directories, which get passed with the -L flag
98100
// This can't be set with a rustpkg flag, only from package scripts
99-
additional_library_paths: ~[Path],
101+
additional_library_paths: HashSet<Path>,
100102
// Any -Z features
101103
experimental_features: Option<~[~str]>
102104
}
@@ -163,7 +165,7 @@ impl Context {
163165
}
164166

165167
pub fn add_library_path(&mut self, p: Path) {
166-
self.rustc_flags.additional_library_paths.push(p);
168+
self.rustc_flags.additional_library_paths.insert(p);
167169
}
168170
}
169171

@@ -227,7 +229,7 @@ impl RustcFlags {
227229
save_temps: false,
228230
target: None,
229231
target_cpu: None,
230-
additional_library_paths: ~[],
232+
additional_library_paths: HashSet::new(),
231233
experimental_features: None
232234
}
233235
}

src/librustpkg/rustpkg.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern mod rustc;
2525
extern mod syntax;
2626

2727
use std::{os, result, run, str, task};
28+
use std::hashmap::HashSet;
2829
pub use std::path::Path;
2930

3031
use extra::workcache;
@@ -840,7 +841,8 @@ pub fn main_args(args: &[~str]) -> int {
840841
save_temps: save_temps,
841842
target: target,
842843
target_cpu: target_cpu,
843-
additional_library_paths: ~[], // No way to set this from the rustpkg command line
844+
additional_library_paths:
845+
HashSet::new(), // No way to set this from the rustpkg command line
844846
experimental_features: experimental_features
845847
};
846848

src/librustpkg/util.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,7 @@ pub fn compile_input(context: &BuildContext,
285285
debug!("a dependency: {}", p.display());
286286
// Pass the directory containing a dependency
287287
// as an additional lib search path
288-
if !addl_lib_search_paths.contains(&p) {
289-
// Might be inefficient, but this set probably
290-
// won't get too large -- tjc
291-
addl_lib_search_paths.push(p);
292-
}
288+
addl_lib_search_paths.insert(p);
293289
});
294290

295291
// Inject the link attributes so we get the right package name and version
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-fast
12+
// aux-build:anon-extern-mod-cross-crate-1.rs
13+
// aux-build:anon-extern-mod-cross-crate-1.rs
14+
extern mod anonexternmod;
15+
16+
pub fn main() { }
17+

0 commit comments

Comments
 (0)