|
3 | 3 | use std::ops; |
4 | 4 |
|
5 | 5 | use rustc_data_structures::outline; |
| 6 | +use thin_vec::ThinVec; |
6 | 7 | use tracing::{debug, instrument}; |
7 | 8 |
|
8 | 9 | use super::interpret::GlobalAlloc; |
@@ -1041,17 +1042,15 @@ impl RawPtrKind { |
1041 | 1042 | } |
1042 | 1043 | } |
1043 | 1044 |
|
1044 | | -// FIXME(panstromek) |
1045 | | -// I'd like to use real ThinVec here, but it fails to borrow check, |
1046 | | -// probably because ThinVec doesn't have #[may_dangle] on Drop impl? |
1047 | | -type ThinVec<T> = Option<Box<Vec<T>>>; |
1048 | | - |
1049 | 1045 | // This collection is almost always empty, so we |
1050 | 1046 | // use thin representation and optimize all methods |
1051 | 1047 | // for that by inlining the empty check |
1052 | | -// and outlining the rest. |
| 1048 | +// and outlining the rest. Note that Option is |
| 1049 | +// technically not needed, because empty ThinVec |
| 1050 | +// points to a static singleton, this version performed |
| 1051 | +// better in our benchmarks |
1053 | 1052 | #[derive(Default, Debug, Clone, TyEncodable, TyDecodable, StableHash, TypeFoldable, TypeVisitable)] |
1054 | | -pub struct StmtDebugInfos<'tcx>(ThinVec<StmtDebugInfo<'tcx>>); |
| 1053 | +pub struct StmtDebugInfos<'tcx>(Option<ThinVec<StmtDebugInfo<'tcx>>>); |
1055 | 1054 |
|
1056 | 1055 | impl<'tcx> StmtDebugInfos<'tcx> { |
1057 | 1056 | pub fn push(&mut self, debuginfo: StmtDebugInfo<'tcx>) { |
@@ -1087,9 +1086,7 @@ impl<'tcx> StmtDebugInfos<'tcx> { |
1087 | 1086 | if debuginfos.is_empty() { |
1088 | 1087 | return; |
1089 | 1088 | }; |
1090 | | - outline(move || { |
1091 | | - self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap().as_mut()) |
1092 | | - }); |
| 1089 | + outline(move || self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap())); |
1093 | 1090 | } |
1094 | 1091 | #[inline] |
1095 | 1092 | pub fn extend(&mut self, debuginfos: &Self) { |
|
0 commit comments