mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
DRY up my new normalize
code
This commit is contained in:
parent
aef9d81eaa
commit
de6a31263a
1 changed files with 12 additions and 14 deletions
|
@ -624,13 +624,7 @@ impl<'a> Normalize<'a> for StrLiteral<'a> {
|
|||
new_segments.push(StrSegment::Plaintext(last_text.into_bump_str()));
|
||||
}
|
||||
|
||||
if new_segments.len() == 1 {
|
||||
if let StrSegment::Plaintext(t) = new_segments[0] {
|
||||
return StrLiteral::PlainLine(t);
|
||||
}
|
||||
}
|
||||
|
||||
StrLiteral::Line(new_segments.into_bump_slice())
|
||||
normalize_str_line(new_segments)
|
||||
}
|
||||
StrLiteral::Block(t) => {
|
||||
let mut new_segments = Vec::new_in(arena);
|
||||
|
@ -642,18 +636,22 @@ impl<'a> Normalize<'a> for StrLiteral<'a> {
|
|||
new_segments.push(StrSegment::Plaintext(last_text.into_bump_str()));
|
||||
}
|
||||
|
||||
if new_segments.len() == 1 {
|
||||
if let StrSegment::Plaintext(t) = new_segments[0] {
|
||||
return StrLiteral::PlainLine(t);
|
||||
}
|
||||
}
|
||||
|
||||
StrLiteral::Line(new_segments.into_bump_slice())
|
||||
normalize_str_line(new_segments)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn normalize_str_line<'a>(new_segments: Vec<'a, StrSegment<'a>>) -> StrLiteral<'a> {
|
||||
if new_segments.len() == 1 {
|
||||
if let StrSegment::Plaintext(t) = new_segments[0] {
|
||||
return StrLiteral::PlainLine(t);
|
||||
}
|
||||
}
|
||||
|
||||
StrLiteral::Line(new_segments.into_bump_slice())
|
||||
}
|
||||
|
||||
fn normalize_str_segments<'a>(
|
||||
arena: &'a Bump,
|
||||
segments: &[StrSegment<'a>],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue