Skip to content

Commit

Permalink
Merge pull request #17 from dtolnay-contrib/hasher
Browse files Browse the repository at this point in the history
Drop aHash dependency in favor of hashbrown's choice of default hasher
  • Loading branch information
pascalkuthe authored Dec 9, 2024
2 parents c11afde + 0bd0b9c commit 5c6534c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
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 <[email protected]>"]
rust-version = "1.61"
rust-version = "1.71"
license = "Apache-2.0"

description = "A high performance library for computing diffs."
Expand All @@ -17,8 +17,7 @@ exclude = [
]

[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

0 comments on commit 5c6534c

Please sign in to comment.