Skip to content

Commit c97aa09

Browse files
committed
iterator instead loop
1 parent 8be3068 commit c97aa09

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/librustc_trans/llvm_util.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,15 @@ pub fn to_llvm_feature(s: &str) -> &str {
113113
}
114114

115115
pub fn target_features(sess: &Session) -> Vec<Symbol> {
116-
let whitelist = target_feature_whitelist(sess);
117116
let target_machine = create_target_machine(sess);
118-
let mut features = Vec::new();
119-
for feature in whitelist {
120-
let llvm_feature = to_llvm_feature(feature);
121-
let ptr = CString::new(llvm_feature).as_ptr();
122-
if unsafe { llvm::LLVMRustHasFeature(target_machine, ptr) } {
123-
features.push(Symbol::intern(feature));
124-
}
125-
}
126-
features
117+
target_feature_whitelist(sess)
118+
.iter()
119+
.filter(|feature| {
120+
let llvm_feature = to_llvm_feature(feature);
121+
let ptr = CString::new(llvm_feature).as_ptr();
122+
unsafe { llvm::LLVMRustHasFeature(target_machine, ptr) }
123+
})
124+
.map(Symbol::intern).collect()
127125
}
128126

129127
pub fn target_feature_whitelist(sess: &Session) -> &'static [&'static str] {

0 commit comments

Comments
 (0)