Skip to content

Commit

Permalink
Remove duplicate hashbrown dependency by moving to basic-toml
Browse files Browse the repository at this point in the history
  • Loading branch information
w4 committed Nov 13, 2024
1 parent ba45e91 commit 66b2f9a
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 120 deletions.
97 changes: 21 additions & 76 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ axum = { version = "0.7", default-features = false, features = [
"tokio",
"http1",
] }
basic-toml = "0.1"
bytes = "1.5"
clap = { version = "4.5.20", default-features = false, features = [
"std",
Expand All @@ -40,14 +41,22 @@ gix = { version = "0.67", default-features = false, features = [
"blob-diff",
"revision",
] }
hashbrown = { version = "0.14", default-features = false, features = [
"serde",
"ahash",
] }
httparse = "1.9"
humantime = "2.1"
itertools = "0.12.1"
md5 = "0.7"
memchr = "2.7"
moka = { version = "0.12.0", features = ["future"] }
path-clean = "1.0.1"
rand = "0.8.5"
rkyv = "0.8"
rkyv = { version = "0.8", features = [
"bytecheck",
"alloc",
], default-features = false }
rocksdb = { version = "0.22", default-features = false, features = ["snappy"] }
rust-ini = "0.21.1"
serde = { version = "1.0", features = ["derive", "rc"] }
Expand All @@ -58,7 +67,6 @@ timeago = { version = "0.4.2", default-features = false }
tokio = { version = "1.19", features = ["full", "tracing"] }
tokio-stream = "0.1"
tokio-util = { version = "0.7.10", features = ["io"] }
toml = { version = "0.8", default-features = false, features = ["parse"] }
tower = "0.5"
tower-http = { version = "0.6", features = ["cors", "timeout"] }
tower-layer = "0.3"
Expand Down Expand Up @@ -87,4 +95,3 @@ rsass = "0.28.0"

[package.metadata.deb]
section = "web"

30 changes: 14 additions & 16 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ ignore = []

[licenses]
allow = [
"MIT",
"Apache-2.0",
"Unicode-3.0",
"Unicode-DFS-2016",
"WTFPL",
"BSL-1.0",
"CC0-1.0",
"BSD-3-Clause",
"ISC",
"Zlib",
"BSD-2-Clause",
"MIT",
"Apache-2.0",
"Unicode-3.0",
"Unicode-DFS-2016",
"WTFPL",
"BSL-1.0",
"CC0-1.0",
"BSD-3-Clause",
"ISC",
"Zlib",
"BSD-2-Clause",
]
confidence-threshold = 0.8
exceptions = []
Expand All @@ -35,17 +35,15 @@ external-default-features = "allow"
allow = []
deny = []
skip = [
{ crate = "[email protected]", reason = "tower has not upgraded to 1.0 yet" },
{ crate = "[email protected]", reason = "gix pulls in two separate versions" },
{ crate = "[email protected]", reason = "gix has not upgraded their version of dashmap" },
{ crate = "[email protected]", reason = "tower has not upgraded to 1.0 yet" },
{ crate = "[email protected]", reason = "gix pulls in two separate versions" },
]
skip-tree = [
{ name = "matchers", reason = "tracing-subscriber's env-filter pulls in an ancient regex version" }
{ name = "matchers", reason = "tracing-subscriber's env-filter pulls in an ancient regex version" },
]

[sources]
unknown-registry = "warn"
unknown-git = "warn"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
allow-git = []

17 changes: 11 additions & 6 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ use crate::{
type ReadmeCacheKey = (PathBuf, Option<Arc<str>>);

pub struct Git {
commits: Cache<(ObjectId, bool), Arc<Commit>>,
readme_cache: Cache<ReadmeCacheKey, Option<(ReadmeFormat, Arc<str>)>>,
open_repositories: Cache<PathBuf, ThreadSafeRepository>,
commits: Cache<(ObjectId, bool), Arc<Commit>, hashbrown::hash_map::DefaultHashBuilder>,
readme_cache: Cache<
ReadmeCacheKey,
Option<(ReadmeFormat, Arc<str>)>,
hashbrown::hash_map::DefaultHashBuilder,
>,
open_repositories:
Cache<PathBuf, ThreadSafeRepository, hashbrown::hash_map::DefaultHashBuilder>,
}

impl Git {
Expand All @@ -51,15 +56,15 @@ impl Git {
commits: Cache::builder()
.time_to_live(Duration::from_secs(30))
.max_capacity(100)
.build(),
.build_with_hasher(hashbrown::hash_map::DefaultHashBuilder::default()),
readme_cache: Cache::builder()
.time_to_live(Duration::from_secs(30))
.max_capacity(100)
.build(),
.build_with_hasher(hashbrown::hash_map::DefaultHashBuilder::default()),
open_repositories: Cache::builder()
.time_to_idle(Duration::from_secs(120))
.max_capacity(100)
.build(),
.build_with_hasher(hashbrown::hash_map::DefaultHashBuilder::default()),
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async fn main() -> Result<(), anyhow::Error> {
run_indexer(db.clone(), args.scan_path.clone(), args.refresh_interval);

let css = {
let theme = toml::from_str::<Theme>(include_str!("../themes/github_light.toml"))
let theme = basic_toml::from_str::<Theme>(include_str!("../themes/github_light.toml"))
.unwrap()
.build_css();
let css = Box::leak(
Expand All @@ -151,7 +151,7 @@ async fn main() -> Result<(), anyhow::Error> {
};

let dark_css = {
let theme = toml::from_str::<Theme>(include_str!("../themes/onedark.toml"))
let theme = basic_toml::from_str::<Theme>(include_str!("../themes/onedark.toml"))
.unwrap()
.build_css();
let css = Box::leak(
Expand Down Expand Up @@ -241,7 +241,13 @@ fn open_db(args: &Args) -> Result<Arc<rocksdb::DB>, anyhow::Error> {
let mut commit_family_options = Options::default();
commit_family_options.set_prefix_extractor(SliceTransform::create(
"commit_prefix",
|input| input.split(|&c| c == b'\0').next().unwrap_or(input),
|input| {
if let Some(offset) = memchr::memchr(b'\0', input) {
&input[offset + 1..]
} else {
input
}
},
None,
));

Expand Down
Loading

0 comments on commit 66b2f9a

Please sign in to comment.