refactor: prefer Arc<str> to String

This commit is contained in:
2026-05-23 18:45:44 +01:00
parent 1ef91cb41e
commit 1843622540
15 changed files with 524 additions and 544 deletions

View File

@@ -175,8 +175,10 @@ fn render_github_fixtures(fixture_root: &Path) -> String {
if let Some(id) = parse_pull_request_file_tree_fixture_name(&file_name) {
let value = read_fixture_value(&entry.path());
pull_request_file_tree_fixtures
.insert(id, read_pull_request_file_tree_fixture(&value, &entry.path()));
pull_request_file_tree_fixtures.insert(
id,
read_pull_request_file_tree_fixture(&value, &entry.path()),
);
continue;
}
@@ -232,12 +234,12 @@ fn render_github_fixtures(fixture_root: &Path) -> String {
output.push_str(&string_literal(&path));
output.push_str(", ");
match reff {
| Some(reff) => {
output.push_str("Some(");
output.push_str(&string_literal(&reff));
output.push(')');
}
| None => output.push_str("None"),
| Some(reff) => {
output.push_str("Some(");
output.push_str(&string_literal(&reff));
output.push(')');
}
| None => output.push_str("None"),
}
output.push_str(") => Some(");
output.push_str(&string_literal(&content));
@@ -291,8 +293,8 @@ fn render_github_fixtures(fixture_root: &Path) -> String {
output.push_str(&string_literal(&id));
output.push_str(", ");
match previous_end_cursor.as_deref() {
| Some(after) => output.push_str(&format!("Some({})", string_literal(after))),
| None => output.push_str("None"),
| Some(after) => output.push_str(&format!("Some({})", string_literal(after))),
| None => output.push_str("None"),
}
output.push_str(") => Some(");
output.push_str(&string_literal(&fixture.json));
@@ -427,9 +429,9 @@ fn issue_fixture_state(issue: &serde_json::Value) -> &'static str {
}
match required_string(issue, &["state"]) {
| "open" => "OPEN",
| "closed" => "CLOSED",
| state => panic!("unsupported pull request state in fixture: {state}"),
| "open" => "OPEN",
| "closed" => "CLOSED",
| state => panic!("unsupported pull request state in fixture: {state}"),
}
}
@@ -498,8 +500,8 @@ fn collect_repo_file_content_fixtures(
let owner = parts[0].clone();
let repo = parts[1].clone();
let reff = match parts[2].as_str() {
| "@default" => None,
| value => Some(value.to_owned()),
| "@default" => None,
| value => Some(value.to_owned()),
};
let virtual_path = parts[3..].join("/");
let content = fs::read_to_string(&path).unwrap_or_else(|err| {