mirror of
https://github.com/rust-lang/cargo
synced 2024-08-28 03:39:31 +00:00
perf(toml): Avoid looking up readme on published packages
Not much of a performance gain; this is mostly done to be consistent with the target work.
This commit is contained in:
parent
0cf29c5713
commit
39f1a210b8
|
@ -243,15 +243,12 @@ impl TomlPackage {
|
|||
}
|
||||
|
||||
pub fn resolved_readme(&self) -> Result<Option<&String>, UnresolvedError> {
|
||||
self.readme
|
||||
.as_ref()
|
||||
.map(|v| {
|
||||
v.resolved().and_then(|sb| match sb {
|
||||
StringOrBool::Bool(_) => Err(UnresolvedError),
|
||||
StringOrBool::String(value) => Ok(value),
|
||||
})
|
||||
})
|
||||
.transpose()
|
||||
let readme = self.readme.as_ref().ok_or(UnresolvedError)?;
|
||||
readme.resolved().and_then(|sb| match sb {
|
||||
StringOrBool::Bool(false) => Ok(None),
|
||||
StringOrBool::Bool(true) => Err(UnresolvedError),
|
||||
StringOrBool::String(value) => Ok(Some(value)),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn resolved_keywords(&self) -> Result<Option<&Vec<String>>, UnresolvedError> {
|
||||
|
|
|
@ -553,7 +553,10 @@ fn resolve_package_toml<'a>(
|
|||
.transpose()?
|
||||
.as_ref(),
|
||||
)
|
||||
.map(|s| manifest::InheritableField::Value(StringOrBool::String(s))),
|
||||
.map(|s| manifest::InheritableField::Value(StringOrBool::String(s)))
|
||||
.or(Some(manifest::InheritableField::Value(StringOrBool::Bool(
|
||||
false,
|
||||
)))),
|
||||
keywords: original_package
|
||||
.keywords
|
||||
.clone()
|
||||
|
|
|
@ -2217,6 +2217,7 @@ authors = []
|
|||
description = "foo"
|
||||
homepage = "foo"
|
||||
documentation = "foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
repository = "foo"
|
||||
resolver = "2"
|
||||
|
|
|
@ -1705,6 +1705,7 @@ version = "0.1.0"
|
|||
authors = ["Zzz"]
|
||||
description = "foo"
|
||||
homepage = "https://example.com/"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
resolver = "2"
|
||||
"#,
|
||||
|
|
|
@ -987,6 +987,7 @@ name = "foo"
|
|||
version = "0.1.0"
|
||||
description = "foo"
|
||||
homepage = "https://example.com/"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
|
||||
[dependencies.opt-dep1]
|
||||
|
@ -1105,6 +1106,7 @@ name = "foo"
|
|||
version = "0.1.0"
|
||||
description = "foo"
|
||||
homepage = "https://example.com/"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
|
||||
[dependencies.bar]
|
||||
|
|
|
@ -227,6 +227,7 @@ publish = true
|
|||
description = "This is a crate"
|
||||
homepage = "https://www.rust-lang.org"
|
||||
documentation = "https://www.rust-lang.org/learn"
|
||||
readme = false
|
||||
keywords = ["cli"]
|
||||
categories = ["development-tools"]
|
||||
license = "MIT"
|
||||
|
@ -383,6 +384,7 @@ edition = "2015"
|
|||
name = "bar"
|
||||
version = "0.2.0"
|
||||
authors = []
|
||||
readme = false
|
||||
|
||||
[dependencies.dep]
|
||||
version = "0.1"
|
||||
|
@ -514,6 +516,7 @@ edition = "2015"
|
|||
name = "bar"
|
||||
version = "0.2.0"
|
||||
authors = []
|
||||
readme = false
|
||||
|
||||
[dependencies.dep]
|
||||
version = "0.1.2"
|
||||
|
@ -927,6 +930,7 @@ edition = "2015"
|
|||
name = "bar"
|
||||
version = "0.2.0"
|
||||
authors = []
|
||||
readme = false
|
||||
|
||||
[dependencies.dep]
|
||||
version = "0.1"
|
||||
|
|
|
@ -1219,6 +1219,7 @@ version = "0.0.1"
|
|||
authors = []
|
||||
exclude = ["*.txt"]
|
||||
description = "foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
|
||||
[package.metadata]
|
||||
|
@ -1293,6 +1294,7 @@ edition = "2015"
|
|||
name = "bar"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
readme = false
|
||||
"#,
|
||||
cargo::core::manifest::MANIFEST_PREAMBLE
|
||||
);
|
||||
|
@ -1360,6 +1362,7 @@ fn package_public_dep() {
|
|||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
readme = false
|
||||
|
||||
[dependencies.bar]
|
||||
version = "1.0.0"
|
||||
|
@ -1378,6 +1381,7 @@ version = "1.0.0"
|
|||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
readme = false
|
||||
|
||||
[dependencies.bar]
|
||||
version = "1.0.0"
|
||||
|
@ -2855,6 +2859,7 @@ fn workspace_overrides_resolver() {
|
|||
edition = "2021"
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
readme = false
|
||||
resolver = "1"
|
||||
"#,
|
||||
cargo::core::manifest::MANIFEST_PREAMBLE
|
||||
|
@ -2874,6 +2879,7 @@ resolver = "1"
|
|||
edition = "2015"
|
||||
name = "baz"
|
||||
version = "0.1.0"
|
||||
readme = false
|
||||
"#,
|
||||
cargo::core::manifest::MANIFEST_PREAMBLE
|
||||
);
|
||||
|
@ -2938,6 +2944,7 @@ authors = []
|
|||
exclude = ["*.txt"]
|
||||
description = "foo"
|
||||
homepage = "https://example.com/"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
cargo::core::manifest::MANIFEST_PREAMBLE
|
||||
|
@ -3032,6 +3039,7 @@ version = "0.0.1"
|
|||
authors = []
|
||||
description = "foo"
|
||||
documentation = "https://example.com/"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
cargo::core::manifest::MANIFEST_PREAMBLE
|
||||
|
@ -3139,6 +3147,7 @@ version = "0.0.1"
|
|||
authors = []
|
||||
description = "foo"
|
||||
homepage = "https://example.com/"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
cargo::core::manifest::MANIFEST_PREAMBLE
|
||||
|
@ -3319,6 +3328,7 @@ version = "0.0.1"
|
|||
authors = []
|
||||
exclude = ["*.txt"]
|
||||
description = "foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
|
||||
[[test]]
|
||||
|
@ -3819,6 +3829,7 @@ include = [
|
|||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
|
@ -3885,6 +3896,7 @@ authors = []
|
|||
include = ["src/lib.rs"]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
|
@ -3956,6 +3968,7 @@ include = [
|
|||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
|
@ -4070,6 +4083,7 @@ include = [
|
|||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
|
@ -4136,6 +4150,7 @@ authors = []
|
|||
include = ["src/main.rs"]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
|
@ -4214,6 +4229,7 @@ include = [
|
|||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
|
||||
[lib]
|
||||
|
@ -4342,6 +4358,7 @@ include = [
|
|||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
|
@ -4411,6 +4428,7 @@ authors = []
|
|||
include = ["src/lib.rs"]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
|
@ -4507,6 +4525,7 @@ include = [
|
|||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
|
||||
[[bin]]
|
||||
|
|
|
@ -1561,6 +1561,7 @@ You may press ctrl-c [..]
|
|||
version = \"0.1.0\"\n\
|
||||
authors = []\n\
|
||||
description = \"foo\"\n\
|
||||
readme = false\n\
|
||||
license = \"MIT\"\n\
|
||||
\n\
|
||||
[dependencies.dep1]\n\
|
||||
|
@ -1675,6 +1676,7 @@ authors = []
|
|||
description = "foo"
|
||||
homepage = "foo"
|
||||
documentation = "foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
repository = "foo"
|
||||
|
||||
|
@ -1934,6 +1936,7 @@ authors = []
|
|||
description = "foo"
|
||||
homepage = "foo"
|
||||
documentation = "foo"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
repository = "foo"
|
||||
|
||||
|
|
|
@ -632,6 +632,7 @@ name = "foo"
|
|||
version = "0.1.0"
|
||||
description = "foo"
|
||||
homepage = "https://example.com/"
|
||||
readme = false
|
||||
license = "MIT"
|
||||
|
||||
[dependencies.bar]
|
||||
|
|
Loading…
Reference in a new issue