refactor: prefer Arc<str> to String
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use gpui::{
|
||||
AppContext, InteractiveElement, IntoElement, ParentElement, StatefulInteractiveElement, Styled,
|
||||
div, img, prelude::FluentBuilder,
|
||||
@@ -65,7 +67,7 @@ impl PullRequestView {
|
||||
let maybe_content = {
|
||||
let data = read_query(&query, cx);
|
||||
if let QueryStatus::Loaded(pr) = data {
|
||||
Some(gpui::SharedString::new(pr.body.as_str()))
|
||||
Some(Arc::clone(&pr.body))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -130,8 +132,8 @@ impl PullRequestView {
|
||||
}
|
||||
|
||||
let merge_text = pr.author.as_ref().map(|author| {
|
||||
let base_branch = pr.base_branch_name.as_str();
|
||||
let head_branch = pr.head_branch_name.as_str();
|
||||
let base_branch = &pr.base_branch_name;
|
||||
let head_branch = &pr.head_branch_name;
|
||||
let str = format!(
|
||||
"{} requested to merge {} into {}",
|
||||
author.login, head_branch, base_branch
|
||||
@@ -172,6 +174,8 @@ impl PullRequestView {
|
||||
)
|
||||
});
|
||||
|
||||
let pr_title = gpui::SharedString::new(Arc::clone(&pr.title));
|
||||
|
||||
let metadata_line =
|
||||
div()
|
||||
.flex()
|
||||
@@ -184,7 +188,7 @@ impl PullRequestView {
|
||||
.flex_row()
|
||||
.items_center()
|
||||
.gap_1p5()
|
||||
.child(img(author.avatar_url.clone()).size_4().rounded_full())
|
||||
.child(img(author.avatar_url.as_ref()).size_4().rounded_full())
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
@@ -222,7 +226,7 @@ impl PullRequestView {
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_start()
|
||||
.child(text(pr.title.clone()).w_full().text_xl().mb_1())
|
||||
.child(text(pr_title).w_full().text_xl().mb_1())
|
||||
.child(metadata_line),
|
||||
)
|
||||
.child(div().flex().flex_col().items_end().gap_1().when_some(
|
||||
|
||||
Reference in New Issue
Block a user