-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid string allocation when git diffing
- Loading branch information
1 parent
7e1463e
commit c96c98c
Showing
6 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod git; | ||
mod rope; | ||
|
||
use std::{ | ||
cell::RefCell, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::hash::Hash; | ||
|
||
use ropey::Rope; | ||
|
||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)] | ||
pub struct RopeLine<'a>(pub ropey::RopeSlice<'a>); | ||
|
||
impl Hash for RopeLine<'_> { | ||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { | ||
for chunk in self.0.chunks() { | ||
chunk.hash(state); | ||
} | ||
} | ||
} | ||
|
||
impl<'a> RopeLine<'a> { | ||
pub fn from_rope(rope: &'a Rope) -> Vec<Self> { | ||
rope.lines().into_iter().map(RopeLine).collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters