Skip to content

Commit

Permalink
Merge pull request #462 from dtolnay/identsize
Browse files Browse the repository at this point in the history
Drop irrelevant capacity field from Ident representation
  • Loading branch information
dtolnay authored May 19, 2024
2 parents 464c2eb + c56c5e6 commit 728eddf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ impl Debug for Group {

#[derive(Clone)]
pub(crate) struct Ident {
sym: String,
sym: Box<str>,
span: Span,
raw: bool,
}
Expand All @@ -795,7 +795,7 @@ impl Ident {

pub fn new_unchecked(string: &str, span: Span) -> Self {
Ident {
sym: string.to_owned(),
sym: Box::from(string),
span,
raw: false,
}
Expand All @@ -809,7 +809,7 @@ impl Ident {

pub fn new_raw_unchecked(string: &str, span: Span) -> Self {
Ident {
sym: string.to_owned(),
sym: Box::from(string),
span,
raw: true,
}
Expand Down Expand Up @@ -886,9 +886,9 @@ where
fn eq(&self, other: &T) -> bool {
let other = other.as_ref();
if self.raw {
other.starts_with("r#") && self.sym == other[2..]
other.starts_with("r#") && *self.sym == other[2..]
} else {
self.sym == other
*self.sym == *other
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/test_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn test_proc_macro2_fallback_size_without_locations() {
assert_eq!(mem::size_of::<proc_macro2::Span>(), 0);
assert_eq!(mem::size_of::<Option<proc_macro2::Span>>(), 1);
assert_eq!(mem::size_of::<proc_macro2::Group>(), 16);
assert_eq!(mem::size_of::<proc_macro2::Ident>(), 32);
assert_eq!(mem::size_of::<proc_macro2::Ident>(), 24);
assert_eq!(mem::size_of::<proc_macro2::Punct>(), 8);
assert_eq!(mem::size_of::<proc_macro2::Literal>(), 24);
assert_eq!(mem::size_of::<proc_macro2::TokenStream>(), 8);
Expand All @@ -34,7 +34,7 @@ fn test_proc_macro2_fallback_size_with_locations() {
assert_eq!(mem::size_of::<proc_macro2::Span>(), 8);
assert_eq!(mem::size_of::<Option<proc_macro2::Span>>(), 12);
assert_eq!(mem::size_of::<proc_macro2::Group>(), 24);
assert_eq!(mem::size_of::<proc_macro2::Ident>(), 40);
assert_eq!(mem::size_of::<proc_macro2::Ident>(), 32);
assert_eq!(mem::size_of::<proc_macro2::Punct>(), 16);
assert_eq!(mem::size_of::<proc_macro2::Literal>(), 32);
assert_eq!(mem::size_of::<proc_macro2::TokenStream>(), 8);
Expand All @@ -50,7 +50,7 @@ fn test_proc_macro2_wrapper_size_without_locations() {
assert_eq!(mem::size_of::<proc_macro2::Span>(), 4);
assert_eq!(mem::size_of::<Option<proc_macro2::Span>>(), 8);
assert_eq!(mem::size_of::<proc_macro2::Group>(), 24);
assert_eq!(mem::size_of::<proc_macro2::Ident>(), 32);
assert_eq!(mem::size_of::<proc_macro2::Ident>(), 24);
assert_eq!(mem::size_of::<proc_macro2::Punct>(), 12);
assert_eq!(mem::size_of::<proc_macro2::Literal>(), 24);
assert_eq!(mem::size_of::<proc_macro2::TokenStream>(), 32);
Expand All @@ -66,7 +66,7 @@ fn test_proc_macro2_wrapper_size_with_locations() {
assert_eq!(mem::size_of::<proc_macro2::Span>(), 12);
assert_eq!(mem::size_of::<Option<proc_macro2::Span>>(), 12);
assert_eq!(mem::size_of::<proc_macro2::Group>(), 32);
assert_eq!(mem::size_of::<proc_macro2::Ident>(), 40);
assert_eq!(mem::size_of::<proc_macro2::Ident>(), 32);
assert_eq!(mem::size_of::<proc_macro2::Punct>(), 20);
assert_eq!(mem::size_of::<proc_macro2::Literal>(), 32);
assert_eq!(mem::size_of::<proc_macro2::TokenStream>(), 32);
Expand Down

0 comments on commit 728eddf

Please sign in to comment.