Skip to content

Commit

Permalink
Avoid needless heap allocation in box_collection
Browse files Browse the repository at this point in the history
  • Loading branch information
F3real committed Sep 24, 2021
1 parent cd3f3cf commit 7a4a556
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/types/box_collection.rs
Expand Up @@ -37,13 +37,13 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
}
}

fn get_std_collection(cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option<String> {
fn get_std_collection(cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option<&'static str> {
if is_ty_param_diagnostic_item(cx, qpath, sym::vec_type).is_some() {
Some(String::from("Vec"))
Some("Vec")
} else if is_ty_param_diagnostic_item(cx, qpath, sym::string_type).is_some() {
Some(String::from("String"))
Some("String")
} else if is_ty_param_diagnostic_item(cx, qpath, sym::hashmap_type).is_some() {
Some(String::from("HashMap"))
Some("HashMap")
} else {
None
}
Expand Down

0 comments on commit 7a4a556

Please sign in to comment.