@@ -81,22 +81,12 @@ use rustc_session::parse::ParseSess;
81
81
use rustc_span::symbol::MacroRulesNormalizedIdent;
82
82
use rustc_span::Span;
83
83
84
- use smallvec::{smallvec, SmallVec};
85
-
86
84
use rustc_data_structures::fx::FxHashMap;
87
85
use rustc_data_structures::sync::Lrc;
88
86
use rustc_span::symbol::Ident;
89
87
use std::borrow::Cow;
90
88
use std::collections::hash_map::Entry::{Occupied, Vacant};
91
89
92
- // One element is enough to cover 95-99% of vectors for most benchmarks. Also, vectors longer than
93
- // one frequently have many elements, not just two or three.
94
- type NamedMatchVec = SmallVec<[NamedMatch; 1]>;
95
-
96
- // This type is used a lot. Make sure it doesn't unintentionally get bigger.
97
- #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
98
- rustc_data_structures::static_assert_size!(NamedMatchVec, 48);
99
-
100
90
/// A unit within a matcher that a `MatcherPos` can refer to. Similar to (and derived from)
101
91
/// `mbe::TokenTree`, but designed specifically for fast and easy traversal during matching.
102
92
/// Notable differences to `mbe::TokenTree`:
@@ -221,7 +211,7 @@ struct MatcherPos {
221
211
/// with one element per metavar decl in the matcher. Each element records token trees matched
222
212
/// against the relevant metavar by the black box parser. An element will be a `MatchedSeq` if
223
213
/// the corresponding metavar decl is within a sequence.
224
- matches: Lrc<NamedMatchVec >,
214
+ matches: Lrc<Vec<NamedMatch> >,
225
215
}
226
216
227
217
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
@@ -246,18 +236,12 @@ impl MatcherPos {
246
236
let mut curr = &mut matches[metavar_idx];
247
237
for _ in 0..seq_depth - 1 {
248
238
match curr {
249
- MatchedSeq(seq) => {
250
- let seq = Lrc::make_mut(seq);
251
- curr = seq.last_mut().unwrap();
252
- }
239
+ MatchedSeq(seq) => curr = seq.last_mut().unwrap(),
253
240
_ => unreachable!(),
254
241
}
255
242
}
256
243
match curr {
257
- MatchedSeq(seq) => {
258
- let seq = Lrc::make_mut(seq);
259
- seq.push(m);
260
- }
244
+ MatchedSeq(seq) => seq.push(m),
261
245
_ => unreachable!(),
262
246
}
263
247
}
@@ -350,7 +334,7 @@ pub(super) fn count_metavar_decls(matcher: &[TokenTree]) -> usize {
350
334
/// ```
351
335
#[derive(Debug, Clone)]
352
336
crate enum NamedMatch {
353
- MatchedSeq(Lrc<NamedMatchVec >),
337
+ MatchedSeq(Vec<NamedMatch >),
354
338
355
339
// A metavar match of type `tt`.
356
340
MatchedTokenTree(rustc_ast::tokenstream::TokenTree),
@@ -388,7 +372,7 @@ pub struct TtParser {
388
372
389
373
/// Pre-allocate an empty match array, so it can be cloned cheaply for macros with many rules
390
374
/// that have no metavars.
391
- empty_matches: Lrc<NamedMatchVec >,
375
+ empty_matches: Lrc<Vec<NamedMatch> >,
392
376
}
393
377
394
378
impl TtParser {
@@ -398,7 +382,7 @@ impl TtParser {
398
382
cur_mps: vec![],
399
383
next_mps: vec![],
400
384
bb_mps: vec![],
401
- empty_matches: Lrc::new(smallvec ![]),
385
+ empty_matches: Lrc::new(vec ![]),
402
386
}
403
387
}
404
388
@@ -452,11 +436,7 @@ impl TtParser {
452
436
} => {
453
437
// Install an empty vec for each metavar within the sequence.
454
438
for metavar_idx in next_metavar..next_metavar + num_metavar_decls {
455
- mp.push_match(
456
- metavar_idx,
457
- seq_depth,
458
- MatchedSeq(self.empty_matches.clone()),
459
- );
439
+ mp.push_match(metavar_idx, seq_depth, MatchedSeq(vec![]));
460
440
}
461
441
462
442
if op == KleeneOp::ZeroOrMore || op == KleeneOp::ZeroOrOne {
0 commit comments