We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 750061b commit 4308b27Copy full SHA for 4308b27
Cargo.lock
Cargo.toml
@@ -52,6 +52,7 @@ strum = { version = "0.18.0", features = ["derive"] }
52
lol_html = "0.2"
53
font-awesome-as-a-crate = { path = "crates/font-awesome-as-a-crate" }
54
dashmap = "3.11.10"
55
+string_cache = "0.8.0"
56
57
# Async
58
tokio = { version = "0.2.22", features = ["rt-threaded"] }
@@ -98,6 +99,7 @@ rand = "0.7.3"
98
99
time = "0.1"
100
git2 = { version = "0.13", default-features = false }
101
sass-rs = "0.2.2"
102
+string_cache_codegen = "0.5.1"
103
104
[[bench]]
105
name = "html_parsing"
build.rs
@@ -19,6 +19,7 @@ fn main() {
19
if let Err(sass_err) = compile_sass() {
20
panic!("Error compiling sass: {}", sass_err);
21
}
22
+ write_known_targets().unwrap();
23
24
25
fn write_git_version() {
@@ -87,3 +88,21 @@ fn compile_sass() -> Result<(), Box<dyn Error>> {
87
88
89
Ok(())
90
91
+
92
+fn write_known_targets() -> std::io::Result<()> {
93
+ use std::io::BufRead;
94
95
+ let targets: Vec<String> = std::process::Command::new("rustc")
96
+ .args(&["--print", "target-list"])
97
+ .output()?
+ .stdout
+ .lines()
+ .filter(|s| s.as_ref().map_or(true, |s| !s.is_empty()))
+ .collect::<std::io::Result<_>>()?;
+ string_cache_codegen::AtomType::new("target::TargetAtom", "target_atom!")
+ .atoms(&targets)
+ .write_to_file(&Path::new(&env::var("OUT_DIR").unwrap()).join("target_atom.rs"))?;
106
107
+ Ok(())
108
+}
src/lib.rs
@@ -26,6 +26,13 @@ mod test;
26
pub mod utils;
27
mod web;
28
29
+#[allow(dead_code)]
30
+mod target {
31
+ //! [`crate::target::TargetAtom`] is an interned string type for rustc targets, such as
32
+ //! `x86_64-unknown-linux-gnu`. See the [`string_cache`] docs for usage examples.
33
+ include!(concat!(env!("OUT_DIR"), "/target_atom.rs"));
34
35
36
use web::page::GlobalAlert;
37
38
// Warning message shown in the navigation bar of every page. Set to `None` to hide it.
src/metrics/mod.rs
@@ -3,6 +3,7 @@ mod macros;
3
4
use self::macros::MetricFromOpts;
5
use crate::db::Pool;
6
+use crate::target::TargetAtom;
7
use crate::BuildQueue;
8
use dashmap::DashMap;
9
use failure::Error;
@@ -81,7 +82,7 @@ metrics! {
81
82
pub(crate) struct RecentlyAccessedReleases {
83
krates: DashMap<i32, Instant>,
84
versions: DashMap<i32, Instant>,
- platforms: DashMap<(i32, String), Instant>,
85
+ platforms: DashMap<(i32, TargetAtom), Instant>,
86
impl RecentlyAccessedReleases {
@@ -93,7 +94,7 @@ impl RecentlyAccessedReleases {
self.krates.insert(krate, Instant::now());
self.versions.insert(version, Instant::now());
self.platforms
- .insert((version, target.to_owned()), Instant::now());
+ .insert((version, TargetAtom::from(target)), Instant::now());
pub(crate) fn gather(&self, metrics: &Metrics) {
0 commit comments