From 75949f3fec66de138c2493376eaa9fd819be55da Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 3 Dec 2024 09:28:04 -0500 Subject: [PATCH] Avoid cloning `String` in marker evaluation (#9598) ## Summary A small TODO that I found interesting. See: https://github.com/astral-sh/pubgrub/pull/35. --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- crates/uv-pep508/src/marker/tree.rs | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6ace74c827b..5e56a95d580f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2683,7 +2683,7 @@ dependencies = [ [[package]] name = "pubgrub" version = "0.2.1" -source = "git+https://github.com/astral-sh/pubgrub?rev=9cd9049a64c7352de2ff3b525b9ae36421b0cc18#9cd9049a64c7352de2ff3b525b9ae36421b0cc18" +source = "git+https://github.com/astral-sh/pubgrub?rev=57832d0588fbb7aab824813481104761dc1c7740#57832d0588fbb7aab824813481104761dc1c7740" dependencies = [ "indexmap", "log", @@ -5675,7 +5675,7 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "version-ranges" version = "0.1.1" -source = "git+https://github.com/astral-sh/pubgrub?rev=9cd9049a64c7352de2ff3b525b9ae36421b0cc18#9cd9049a64c7352de2ff3b525b9ae36421b0cc18" +source = "git+https://github.com/astral-sh/pubgrub?rev=57832d0588fbb7aab824813481104761dc1c7740#57832d0588fbb7aab824813481104761dc1c7740" dependencies = [ "smallvec", ] diff --git a/Cargo.toml b/Cargo.toml index c6c9af9e8878..3d55edafe383 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -130,7 +130,7 @@ petgraph = { version = "0.6.5" } platform-info = { version = "2.0.3" } proc-macro2 = { version = "1.0.86" } procfs = { version = "0.17.0", default-features = false, features = ["flate2"] } -pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "9cd9049a64c7352de2ff3b525b9ae36421b0cc18" } +pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "57832d0588fbb7aab824813481104761dc1c7740" } quote = { version = "1.0.37" } rayon = { version = "1.10.0" } reflink-copy = { version = "0.1.19" } @@ -175,7 +175,7 @@ unicode-width = { version = "0.1.13" } unscanny = { version = "0.1.0" } url = { version = "2.5.2", features = ["serde"] } urlencoding = { version = "2.1.3" } -version-ranges = { git = "https://github.com/astral-sh/pubgrub", rev = "9cd9049a64c7352de2ff3b525b9ae36421b0cc18" } +version-ranges = { git = "https://github.com/astral-sh/pubgrub", rev = "57832d0588fbb7aab824813481104761dc1c7740" } walkdir = { version = "2.5.0" } which = { version = "7.0.0", features = ["regex"] } windows-registry = { version = "0.3.0" } diff --git a/crates/uv-pep508/src/marker/tree.rs b/crates/uv-pep508/src/marker/tree.rs index a3542f2eb712..f3b43aea000a 100644 --- a/crates/uv-pep508/src/marker/tree.rs +++ b/crates/uv-pep508/src/marker/tree.rs @@ -893,8 +893,6 @@ impl MarkerTree { } } - // todo(ibraheem): avoid cloning here, `contains` should accept `&impl Borrow` - let l_string = &l_string.to_string(); if range.contains(l_string) { return tree.evaluate_reporter_impl(env, extras, reporter); }