Introduce a new fingerprint field to TextSummary

This is calculated in `Rope` and uses the `bromberg_sl2` homomorphic
hash function to determine the fingerprint of a single chunk and
compose each chunk fingerprint into a single fingerprint for the entire
rope that is equivalent to hashing all the rope's bytes at once.
This commit is contained in:
Antonio Scandurra
2022-06-17 12:12:37 +02:00
parent cef85f5d84
commit c31a233aad
6 changed files with 33 additions and 22 deletions
+1 -13
View File
@@ -370,22 +370,10 @@ impl FoldMap {
if fold.end > fold.start {
let output_text = "…";
let chars = output_text.chars().count() as u32;
let lines = Point::new(0, output_text.len() as u32);
let lines_utf16 =
PointUtf16::new(0, output_text.encode_utf16().count() as u32);
new_transforms.push(
Transform {
summary: TransformSummary {
output: TextSummary {
bytes: output_text.len(),
lines,
lines_utf16,
first_line_chars: chars,
last_line_chars: chars,
longest_row: 0,
longest_row_chars: chars,
},
output: TextSummary::from(output_text),
input: new_buffer.text_summary_for_range(fold.start..fold.end),
},
output_text: Some(output_text),
+1 -9
View File
@@ -1923,15 +1923,7 @@ impl MultiBufferSnapshot {
);
if range.end > end_before_newline {
summary.add_assign(&D::from_text_summary(&TextSummary {
bytes: 1,
lines: Point::new(1 as u32, 0),
lines_utf16: PointUtf16::new(1 as u32, 0),
first_line_chars: 0,
last_line_chars: 0,
longest_row: 0,
longest_row_chars: 0,
}));
summary.add_assign(&D::from_text_summary(&TextSummary::from("\n")));
}
cursor.next(&());