From 83c7e7bd950d8cbc2f35e03de6a92ded8aa3ea51 Mon Sep 17 00:00:00 2001 From: Piotr Jastrzebski Date: Sun, 7 Jul 2024 12:38:37 +0200 Subject: [PATCH 1/2] Remove unneeded allocation Signed-off-by: Piotr Jastrzebski --- core/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/util.rs b/core/util.rs index d3684750a..7c5df802d 100644 --- a/core/util.rs +++ b/core/util.rs @@ -1,6 +1,6 @@ pub fn normalize_ident(ident: &str) -> String { if ident.starts_with('"') && ident.ends_with('"') { - ident[1..ident.len() - 1].to_string().to_lowercase() + ident[1..ident.len() - 1].to_lowercase() } else { ident.to_lowercase() } From 5eea42099434029c73d7e2645ef1edda91736d1f Mon Sep 17 00:00:00 2001 From: Piotr Jastrzebski Date: Sun, 7 Jul 2024 12:42:56 +0200 Subject: [PATCH 2/2] Simplify normalize_ident Signed-off-by: Piotr Jastrzebski --- core/util.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/util.rs b/core/util.rs index 7c5df802d..d87b2df97 100644 --- a/core/util.rs +++ b/core/util.rs @@ -1,7 +1,6 @@ -pub fn normalize_ident(ident: &str) -> String { +pub fn normalize_ident(mut ident: &str) -> String { if ident.starts_with('"') && ident.ends_with('"') { - ident[1..ident.len() - 1].to_lowercase() - } else { - ident.to_lowercase() + ident = &ident[1..ident.len() - 1]; } + ident.to_lowercase() }