Immediately create an Option
instead of reallocating for it later
This commit is contained in:
parent
eef70a9db5
commit
b4acf7a51e
2 changed files with 6 additions and 6 deletions
|
@ -68,7 +68,8 @@ pub(super) const UNKNOWN_COLUMN_NUMBER: c_uint = 0;
|
|||
|
||||
const NO_SCOPE_METADATA: Option<&DIScope> = None;
|
||||
/// A function that returns an empty list of generic parameter debuginfo nodes.
|
||||
const NO_GENERICS: for<'ll> fn(&CodegenCx<'ll, '_>) -> SmallVec<&'ll DIType> = |_| SmallVec::new();
|
||||
const NO_GENERICS: for<'ll> fn(&CodegenCx<'ll, '_>) -> SmallVec<Option<&'ll DIType>> =
|
||||
|_| SmallVec::new();
|
||||
|
||||
// SmallVec is used quite a bit in this module, so create a shorthand.
|
||||
// The actual number of elements is not so important.
|
||||
|
@ -1287,7 +1288,7 @@ fn build_union_type_di_node<'ll, 'tcx>(
|
|||
fn build_generic_type_param_di_nodes<'ll, 'tcx>(
|
||||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> SmallVec<&'ll DIType> {
|
||||
) -> SmallVec<Option<&'ll DIType>> {
|
||||
if let ty::Adt(def, args) = *ty.kind() {
|
||||
if args.types().next().is_some() {
|
||||
let generics = cx.tcx.generics_of(def.did());
|
||||
|
@ -1297,7 +1298,7 @@ fn build_generic_type_param_di_nodes<'ll, 'tcx>(
|
|||
kind.as_type().map(|ty| {
|
||||
let actual_type = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
|
||||
let actual_type_di_node = type_di_node(cx, actual_type);
|
||||
cx.create_template_type_parameter(name.as_str(), actual_type_di_node)
|
||||
Some(cx.create_template_type_parameter(name.as_str(), actual_type_di_node))
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
|
|
@ -257,7 +257,7 @@ pub(super) fn build_type_with_children<'ll, 'tcx>(
|
|||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
stub_info: StubInfo<'ll, 'tcx>,
|
||||
members: impl FnOnce(&CodegenCx<'ll, 'tcx>, &'ll DIType) -> SmallVec<&'ll DIType>,
|
||||
generics: impl FnOnce(&CodegenCx<'ll, 'tcx>) -> SmallVec<&'ll DIType>,
|
||||
generics: impl FnOnce(&CodegenCx<'ll, 'tcx>) -> SmallVec<Option<&'ll DIType>>,
|
||||
) -> DINodeCreationResult<'ll> {
|
||||
assert_eq!(debug_context(cx).type_map.di_node_for_unique_id(stub_info.unique_type_id), None);
|
||||
|
||||
|
@ -265,8 +265,7 @@ pub(super) fn build_type_with_children<'ll, 'tcx>(
|
|||
|
||||
let members: SmallVec<_> =
|
||||
members(cx, stub_info.metadata).into_iter().map(|node| Some(node)).collect();
|
||||
let generics: SmallVec<Option<&'ll DIType>> =
|
||||
generics(cx).into_iter().map(|node| Some(node)).collect();
|
||||
let generics = generics(cx);
|
||||
|
||||
if !(members.is_empty() && generics.is_empty()) {
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue