Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Document RopeFingerprint

Antonio Scandurra1f649e52dedd
diff --git a/crates/rope/src/rope.rs b/crates/rope/src/rope.rs
index 74cc9a6789e..d0796cfc6ac 100644
--- a/crates/rope/src/rope.rs
+++ b/crates/rope/src/rope.rs
@@ -25,6 +25,10 @@ const CHUNK_BASE: usize = 6;
#[cfg(not(test))]
const CHUNK_BASE: usize = 16;
+/// Type alias to [HashMatrix], an implementation of a homomorphic hash function. Two [Rope] instances
+/// containing the same text will produce the same fingerprint. This hash function is special in that
+/// it allows us to hash individual chunks and aggregate them up the [Rope]'s tree, with the resulting
+/// hash being equivalent to hashing all the text contained in the [Rope] at once.
pub type RopeFingerprint = HashMatrix;
#[derive(Clone, Default, Debug)]
@@ -858,7 +862,7 @@ impl sum_tree::Item for Chunk {
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct ChunkSummary {
text: TextSummary,
- fingerprint: HashMatrix,
+ fingerprint: RopeFingerprint,
}
impl<'a> From<&'a str> for ChunkSummary {