From 84c5c4e581a566b6a032a4ce37ac5541859f4382 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Wed, 27 Aug 2025 17:19:32 +0000 Subject: [PATCH] core/util: emit literal, cow instead of replace --- core/util.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/util.rs b/core/util.rs index 7697784ef..d38ed1a6f 100644 --- a/core/util.rs +++ b/core/util.rs @@ -1017,7 +1017,11 @@ pub fn cast_real_to_integer(float: f64) -> std::result::Result { // we don't need to verify the numeric literal here, as it is already verified by the parser pub fn parse_numeric_literal(text: &str) -> Result { // a single extra underscore ("_") character can exist between any two digits - let text = text.replace("_", ""); + let text = if text.contains('_') { + std::borrow::Cow::Owned(text.replace('_', "")) + } else { + std::borrow::Cow::Borrowed(text) + }; if text.starts_with("0x") || text.starts_with("0X") { let value = u64::from_str_radix(&text[2..], 16)? as i64;