Support specifying crate names and versions separated by `@` character
rather than `-`. Since `@` are not valid in crate names, this
makes splitting the tokens trivial and free of regular expressions. Effectively, the `@` variant is roughly 180% faster:
```
* CRATES with '@' separator
real 952 it/s
user 952 it/s
* CRATES with '-' separator
real 339 it/s
user 339 it/s
```
Signed-off-by: Michał Górny <
mgorny@gentoo.org>
---
eclass/cargo.eclass | 24 +++++---
eclass/tests/cargo-bench.sh | 111 +++++++++++++++++++-----------------
2 files changed, 75 insertions(+), 60 deletions(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index d97bb0df9348..8618c90bd986 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -59,12 +59,16 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
# Bash string containing all crates that are to be downloaded.
# It is used by cargo_crate_uris.
#
+# Ideally, crate names and versions should be separated by a `@`
+# character. A legacy syntax using hyphen is also supported but it is
+# much slower.
+#
# Example:
# @CODE
# CRATES="
-# metal-1.2.3
-# bar-4.5.6
-# iron_oxide-0.0.1
+# metal@1.2.3
+# bar@4.5.6
+# iron_oxide@0.0.1
# "
# inherit cargo
# ...
@@ -182,10 +186,16 @@ _cargo_set_crate_uris() {
CARGO_CRATE_URIS=
for crate in ${crates}; do
local name version url
- [[ $crate =~ $regex ]] || die "Could not parse name and version from c