1
Fork 0

iterator instead loop

This commit is contained in:
Артём Павлов [Artyom Pavlov] 2018-02-11 02:36:22 +03:00
parent 8be306840f
commit c97aa09117
No known key found for this signature in database
GPG key ID: 13A9399FB77E335C

View file

@ -113,17 +113,15 @@ pub fn to_llvm_feature(s: &str) -> &str {
} }
pub fn target_features(sess: &Session) -> Vec<Symbol> { pub fn target_features(sess: &Session) -> Vec<Symbol> {
let whitelist = target_feature_whitelist(sess);
let target_machine = create_target_machine(sess); let target_machine = create_target_machine(sess);
let mut features = Vec::new(); target_feature_whitelist(sess)
for feature in whitelist { .iter()
let llvm_feature = to_llvm_feature(feature); .filter(|feature| {
let ptr = CString::new(llvm_feature).as_ptr(); let llvm_feature = to_llvm_feature(feature);
if unsafe { llvm::LLVMRustHasFeature(target_machine, ptr) } { let ptr = CString::new(llvm_feature).as_ptr();
features.push(Symbol::intern(feature)); unsafe { llvm::LLVMRustHasFeature(target_machine, ptr) }
} })
} .map(Symbol::intern).collect()
features
} }
pub fn target_feature_whitelist(sess: &Session) -> &'static [&'static str] { pub fn target_feature_whitelist(sess: &Session) -> &'static [&'static str] {