Conversation
396c22d to
ae7ce38
Compare
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
ae7ce38 to
cffe8de
Compare
crates/ty_python_semantic/src/types/infer/builder/type_expression.rs
Outdated
Show resolved
Hide resolved
797d90e to
83e0cc5
Compare
|
AlexWaygood
left a comment
There was a problem hiding this comment.
This is great! We could probably also e.g. adjust the signature of Type::string_literal() to take a Cow<CompactString> instead of &str, if that salsa change lands.
I think that would require one more |
83e0cc5 to
d2d4555
Compare
I didn't end up doing this as part of this PR but the necessary changes are in place in the Salsa version that we use now |
Summary
We call
specializeorto_specialized_classin many places with a fixed number of specializations, and probably often with the very same arguments.Today's
specializeimplementation always collectes all specializationinto a
Box<[T]>to perform the Salsa lookup. However, thatBoxis immediately discarded if the value was interned before.This PR changes
specializeto take aCow<[T]>, allowing allocation-free lookups if the number of specialization-items are known at compile time (or we already have a slice). Call-sites where this isn't the case now have to collect to aVec, but that's no different to what we do today, except that the cost is visible at the call site.Codspeed shows a 1-3% perf improvement on different benchmarks.
Requires salsa-rs/salsa#1054
Test Plan
cargo test