[ty] Reduce number of inline stored definitions per place (#19409)

This commit is contained in:
Micha Reiser 2025-07-18 18:28:46 +02:00 committed by GitHub
parent e6e029a8b7
commit 630c7a3152
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 36 additions and 36 deletions

View file

@ -107,7 +107,7 @@ pub struct Definitions<'db> {
impl<'db> Definitions<'db> {
pub(crate) fn single(definition: Definition<'db>) -> Self {
Self {
definitions: smallvec::smallvec![definition],
definitions: smallvec::smallvec_inline![definition],
}
}

View file

@ -10,7 +10,7 @@ use ruff_index::{IndexVec, newtype_index};
use ruff_python_ast as ast;
use ruff_python_ast::name::Name;
use rustc_hash::FxHasher;
use smallvec::{SmallVec, smallvec};
use smallvec::SmallVec;
use crate::Db;
use crate::ast_node_ref::AstNodeRef;
@ -162,10 +162,10 @@ impl TryFrom<ast::ExprRef<'_>> for PlaceExpr {
}
impl PlaceExpr {
pub(crate) fn name(name: Name) -> Self {
pub(crate) const fn name(name: Name) -> Self {
Self {
root_name: name,
sub_segments: smallvec![],
sub_segments: SmallVec::new_const(),
}
}

View file

@ -71,16 +71,12 @@ impl ScopedDefinitionId {
}
}
/// Can keep inline this many live bindings or declarations per place at a given time; more will
/// go to heap.
const INLINE_DEFINITIONS_PER_PLACE: usize = 4;
/// Live declarations for a single place at some point in control flow, with their
/// corresponding reachability constraints.
#[derive(Clone, Debug, Default, PartialEq, Eq, salsa::Update, get_size2::GetSize)]
pub(super) struct Declarations {
/// A list of live declarations for this place, sorted by their `ScopedDefinitionId`
live_declarations: SmallVec<[LiveDeclaration; INLINE_DEFINITIONS_PER_PLACE]>,
live_declarations: SmallVec<[LiveDeclaration; 2]>,
}
/// One of the live declarations for a single place at some point in control flow.
@ -199,7 +195,7 @@ pub(super) struct Bindings {
/// "unbound" binding.
unbound_narrowing_constraint: Option<ScopedNarrowingConstraint>,
/// A list of live bindings for this place, sorted by their `ScopedDefinitionId`
live_bindings: SmallVec<[LiveBinding; INLINE_DEFINITIONS_PER_PLACE]>,
live_bindings: SmallVec<[LiveBinding; 2]>,
}
impl Bindings {