Skip to content

Commit 5a69929

Browse files
committed
Simplify arg capacity calculations.
Currently they try to be very precise. But they are wrong, i.e. they don't match what's happening in the loop below. This code isn't hot enough for it to matter that much.
1 parent f78592f commit 5a69929

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/abi.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,10 @@ pub trait FnAbiGccExt<'gcc, 'tcx> {
107107
impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
108108
fn gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> (Type<'gcc>, Vec<Type<'gcc>>, bool, FxHashSet<usize>) {
109109
let mut on_stack_param_indices = FxHashSet::default();
110-
let args_capacity: usize = self.args.iter().map(|arg|
111-
if arg.pad.is_some() {
112-
1
113-
}
114-
else {
115-
0
116-
} +
117-
if let PassMode::Pair(_, _) = arg.mode {
118-
2
119-
} else {
120-
1
121-
}
122-
).sum();
110+
111+
// This capacity calculation is approximate.
123112
let mut argument_tys = Vec::with_capacity(
124-
if let PassMode::Indirect { .. } = self.ret.mode {
125-
1
126-
}
127-
else {
128-
0
129-
} + args_capacity,
113+
self.args.len() + if let PassMode::Indirect { .. } = self.ret.mode { 1 } else { 0 }
130114
);
131115

132116
let return_ty =

0 commit comments

Comments
 (0)