Skip to content

Drop aHash dependency in favor of hashbrown's choice of default hasher #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
toolchain:
- "1.65"
- "1.71"
- stable
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "imara-diff"
version = "0.1.7"
edition = "2021"
authors = ["pascalkuthe <pascalkuthe@pm.me>"]
rust-version = "1.61"
rust-version = "1.71"
license = "Apache-2.0"

description = "A high performance library for computing diffs."
Expand All @@ -20,8 +20,7 @@ maintenance = { status = "actively-developed" }


[dependencies]
ahash = "0.8.0"
hashbrown = { version = "0.15", default-features = false, features = ["inline-more"] }
hashbrown = { version = "0.15", default-features = false, features = ["default-hasher", "inline-more"] }

[features]
default = ["unified_diff"]
Expand Down
6 changes: 3 additions & 3 deletions src/intern.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::hash::Hash;
use std::hash::{BuildHasher as _, Hash};
use std::ops::Index;

use ahash::RandomState;
use hashbrown::hash_table::{Entry, HashTable};
use hashbrown::DefaultHashBuilder as RandomState;

/// A token represented as an interned integer.
///
Expand Down Expand Up @@ -114,7 +114,7 @@ impl<T: Hash + Eq> Interner<T> {
Interner {
tokens: Vec::with_capacity(capacity),
table: HashTable::with_capacity(capacity),
hasher: RandomState::new(),
hasher: RandomState::default(),
}
}

Expand Down
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ mod tests;
/// `imara-diff` supports multiple different algorithms
/// for computing an edit sequence.
/// These algorithms have different performance and all produce different output.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
pub enum Algorithm {
/// A variation of the [`patience` diff algorithm described by Bram Cohen's blog post](https://bramcohen.livejournal.com/73318.html)
/// that uses a histogram to find the least common LCS.
Expand Down Expand Up @@ -199,6 +199,7 @@ pub enum Algorithm {
/// fallback to Myers algorithm. However this detection has a nontrivial overhead, so
/// if its known upfront that the sort of tokens is very small `Myers` algorithm should
/// be used instead.
#[default]
Histogram,
/// An implementation of the linear space variant of
/// [Myers `O((N+M)D)` algorithm](http://www.xmailserver.org/diff2.pdf).
Expand Down Expand Up @@ -230,12 +231,6 @@ impl Algorithm {
const ALL: [Self; 2] = [Algorithm::Histogram, Algorithm::Myers];
}

impl Default for Algorithm {
fn default() -> Self {
Algorithm::Histogram
}
}

/// Computes an edit-script that transforms `input.before` into `input.after` using
/// the specified `algorithm`
/// The edit-script is passed to `sink.process_change` while it is produced.
Expand Down
2 changes: 1 addition & 1 deletion src/myers/middle_snake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<const BACK: bool> MiddleSnakeSearch<BACK> {
k -= 2;
}

(best_score > 0).then(|| (best_token_idx1, best_token_idx2))
(best_score > 0).then_some((best_token_idx1, best_token_idx2))
}
}

Expand Down
Loading