if $c:expr { Some($r:expr) } else { None }
=>> $c.then(|| $r)
This commit is contained in:
parent
af3c8b2726
commit
8751fa1a9a
54 changed files with 159 additions and 281 deletions
|
@ -412,11 +412,7 @@ fn get_pgo_sample_use_path(config: &ModuleConfig) -> Option<CString> {
|
|||
}
|
||||
|
||||
fn get_instr_profile_output_path(config: &ModuleConfig) -> Option<CString> {
|
||||
if config.instrument_coverage {
|
||||
Some(CString::new("default_%m_%p.profraw").unwrap())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
config.instrument_coverage.then(|| CString::new("default_%m_%p.profraw").unwrap())
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn llvm_optimize(
|
||||
|
@ -451,11 +447,10 @@ pub(crate) unsafe fn llvm_optimize(
|
|||
None
|
||||
};
|
||||
|
||||
let mut llvm_profiler = if cgcx.prof.llvm_recording_enabled() {
|
||||
Some(LlvmSelfProfiler::new(cgcx.prof.get_self_profiler().unwrap()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut llvm_profiler = cgcx
|
||||
.prof
|
||||
.llvm_recording_enabled()
|
||||
.then(|| LlvmSelfProfiler::new(cgcx.prof.get_self_profiler().unwrap()));
|
||||
|
||||
let llvm_selfprofiler =
|
||||
llvm_profiler.as_mut().map(|s| s as *mut _ as *mut c_void).unwrap_or(std::ptr::null_mut());
|
||||
|
|
|
@ -402,12 +402,8 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||
|
||||
let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod());
|
||||
|
||||
let coverage_cx = if tcx.sess.instrument_coverage() {
|
||||
let covctx = coverageinfo::CrateCoverageContext::new();
|
||||
Some(covctx)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let coverage_cx =
|
||||
tcx.sess.instrument_coverage().then(coverageinfo::CrateCoverageContext::new);
|
||||
|
||||
let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None {
|
||||
let dctx = debuginfo::CodegenUnitDebugContext::new(llmod);
|
||||
|
|
|
@ -154,7 +154,7 @@ fn struct_llfields<'a, 'tcx>(
|
|||
} else {
|
||||
debug!("struct_llfields: offset: {:?} stride: {:?}", offset, layout.size);
|
||||
}
|
||||
let field_remapping = if padding_used { Some(field_remapping) } else { None };
|
||||
let field_remapping = padding_used.then(|| field_remapping);
|
||||
(result, packed, field_remapping)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue