-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Avoid most allocations in Canonicalizer
.
#52342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
|
||
use infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin}; | ||
use rustc_data_structures::indexed_vec::IndexVec; | ||
use rustc_data_structures::small_vec::SmallVec; | ||
use rustc_data_structures::sync::Lrc; | ||
use serialize::UseSpecializedDecodable; | ||
use std::ops::Index; | ||
|
@@ -74,6 +75,10 @@ pub struct CanonicalVarValues<'tcx> { | |
pub var_values: IndexVec<CanonicalVar, Kind<'tcx>>, | ||
} | ||
|
||
/// Like CanonicalVarValues, but for use in places where a SmallVec is | ||
/// appropriate. | ||
pub type SmallCanonicalVarValues<'tcx> = SmallVec<[Kind<'tcx>; 8]>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just use this everywhere...? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because |
||
|
||
/// Information about a canonical variable that is included with the | ||
/// canonical value. This is sufficient information for code to create | ||
/// a copy of the canonical value in some other inference context, | ||
|
@@ -281,10 +286,6 @@ BraceStructLiftImpl! { | |
} | ||
|
||
impl<'tcx> CanonicalVarValues<'tcx> { | ||
fn iter<'a>(&'a self) -> impl Iterator<Item = Kind<'tcx>> + 'a { | ||
self.var_values.iter().cloned() | ||
} | ||
|
||
fn len(&self) -> usize { | ||
self.var_values.len() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just return this? I guess it's more efficient this way...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Copying the
SmallCanonicalVars
reduces the size of the win by about 20--25%. I figure we need every saving we can get for NLL!