@@ -17,6 +17,10 @@ use crate::{
1717
1818use super :: { AttrLocation , AttrPart , AttrPositions , attr_positions, define_generator} ;
1919
20+ /// Visitors with less than this number of fields/variants will be marked `#[inline]`.
21+ // TODO: Is this the ideal value?
22+ const INLINE_LIMIT : usize = 5 ;
23+
2024/// Generator for `Visit` and `VisitMut` traits.
2125pub struct VisitGenerator ;
2226
@@ -422,10 +426,9 @@ impl VisitBuilder<'_> {
422426 field_visits_mut. extend ( leave_scope) ;
423427 }
424428
425- // `#[inline]` if there are 5 or less fields visited
426- // TODO: Is this ideal?
429+ // `#[inline]` if there are `INLINE_LIMIT` or less fields visited
427430 let maybe_inline_attr =
428- if field_visits_count <= 5 { quote ! ( #[ inline] ) } else { quote ! ( ) } ;
431+ if field_visits_count <= INLINE_LIMIT { quote ! ( #[ inline] ) } else { quote ! ( ) } ;
429432
430433 self . walk_fns . extend ( quote ! {
431434 ///@@line_break
@@ -592,9 +595,9 @@ impl VisitBuilder<'_> {
592595 quote ! ( )
593596 } ;
594597
595- // `#[inline]` if there are 5 or less match cases
596- // TODO: Is this ideal?
597- let maybe_inline_attr = if match_arm_count <= 5 { quote ! ( #[ inline] ) } else { quote ! ( ) } ;
598+ // `#[inline]` if there are `INLINE_LIMIT` or less fields visited
599+ let maybe_inline_attr =
600+ if match_arm_count <= INLINE_LIMIT { quote ! ( #[ inline] ) } else { quote ! ( ) } ;
598601
599602 self . walk_fns . extend ( quote ! {
600603 ///@@line_break
0 commit comments