Skip to content

Commit 58fa1d7

Browse files
authored
[ty] Use CompactStr for StringLiteralType (#21497)
1 parent d9fc0f0 commit 58fa1d7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

crates/ty_python_semantic/src/types.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use compact_str::{CompactString, ToCompactString};
12
use infer::nearest_enclosing_class;
23
use itertools::{Either, Itertools};
34
use ruff_db::parsed::parsed_module;
@@ -7497,7 +7498,7 @@ impl<'db> Type<'db> {
74977498
Type::SpecialForm(special_form) => Type::string_literal(db, special_form.repr()),
74987499
Type::KnownInstance(known_instance) => Type::StringLiteral(StringLiteralType::new(
74997500
db,
7500-
known_instance.repr(db).to_string().into_boxed_str(),
7501+
known_instance.repr(db).to_compact_string(),
75017502
)),
75027503
// TODO: handle more complex types
75037504
_ => KnownClass::Str.to_instance(db),
@@ -7519,7 +7520,7 @@ impl<'db> Type<'db> {
75197520
Type::SpecialForm(special_form) => Type::string_literal(db, special_form.repr()),
75207521
Type::KnownInstance(known_instance) => Type::StringLiteral(StringLiteralType::new(
75217522
db,
7522-
known_instance.repr(db).to_string().into_boxed_str(),
7523+
known_instance.repr(db).to_compact_string(),
75237524
)),
75247525
// TODO: handle more complex types
75257526
_ => KnownClass::Str.to_instance(db),
@@ -12388,7 +12389,7 @@ impl<'db> IntersectionType<'db> {
1238812389
#[derive(PartialOrd, Ord)]
1238912390
pub struct StringLiteralType<'db> {
1239012391
#[returns(deref)]
12391-
value: Box<str>,
12392+
value: CompactString,
1239212393
}
1239312394

1239412395
// The Salsa heap is tracked separately.

crates/ty_server/src/server/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ where
436436
.with_failure_code(server::ErrorCode::InternalError)
437437
}
438438

439-
/// Sends back a response to the server, but only if the request wasn't cancelled.
439+
/// Sends back a response to the client, but only if the request wasn't cancelled.
440440
fn respond<Req>(
441441
id: &RequestId,
442442
result: Result<<<Req as RequestHandler>::RequestType as Request>::Result>,

0 commit comments

Comments
 (0)