mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-20 10:30:56 +00:00
Remove unnecessary string cloning from the parser (#9884)
Closes https://github.com/astral-sh/ruff/issues/9869.
This commit is contained in:
parent
7ca515c0aa
commit
6f0e4ad332
11 changed files with 227 additions and 119 deletions
|
@ -949,7 +949,7 @@ impl Ranged for FStringExpressionElement {
|
|||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct FStringLiteralElement {
|
||||
pub range: TextRange,
|
||||
pub value: String,
|
||||
pub value: Box<str>,
|
||||
}
|
||||
|
||||
impl Ranged for FStringLiteralElement {
|
||||
|
@ -962,7 +962,7 @@ impl Deref for FStringLiteralElement {
|
|||
type Target = str;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.value.as_str()
|
||||
&self.value
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1607,7 +1607,7 @@ impl Default for BytesLiteralValueInner {
|
|||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct BytesLiteral {
|
||||
pub range: TextRange,
|
||||
pub value: Vec<u8>,
|
||||
pub value: Box<[u8]>,
|
||||
}
|
||||
|
||||
impl Ranged for BytesLiteral {
|
||||
|
@ -1620,7 +1620,7 @@ impl Deref for BytesLiteral {
|
|||
type Target = [u8];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.value.as_slice()
|
||||
&self.value
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue