mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 15:24:48 +01:00
feat: hash is a public ext
This commit is contained in:
parent
d22446ee10
commit
97b7504098
3 changed files with 8 additions and 2 deletions
|
@ -145,8 +145,7 @@ impl ControllerWorker<TextChange> for BufferWorker {
|
|||
let new_local_v = branch.local_version();
|
||||
|
||||
let hash = if timer.step() {
|
||||
let hash = xxhash_rust::xxh3::xxh3_64(branch.content().to_string().as_bytes());
|
||||
Some(i64::from_ne_bytes(hash.to_ne_bytes()))
|
||||
Some(crate::hash(branch.content().to_string()))
|
||||
} else { None };
|
||||
|
||||
let tc = crate::api::change::TextChange {
|
||||
|
|
|
@ -49,6 +49,11 @@ pub async fn select_buffer(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn hash(data: impl AsRef<[u8]>) -> i64 {
|
||||
let hash = xxhash_rust::xxh3::xxh3_64(data.as_ref());
|
||||
i64::from_ne_bytes(hash.to_ne_bytes())
|
||||
}
|
||||
|
||||
/// wraps sender and receiver to allow mutable field with immutable ref
|
||||
#[derive(Debug)]
|
||||
pub struct InternallyMutable<T> {
|
||||
|
|
|
@ -149,3 +149,5 @@ pub use errors::Result;
|
|||
pub use client::Client;
|
||||
|
||||
pub use workspace::Workspace;
|
||||
|
||||
pub use ext::hash;
|
||||
|
|
Loading…
Reference in a new issue