Skip to content

Commit 1ed74f7

Browse files
committed
use Buffers implementation from gix-utils
1 parent 86cdb42 commit 1ed74f7

File tree

7 files changed

+4
-92
lines changed

7 files changed

+4
-92
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-filter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ gix-trace = { version = "^0.1.3", path = "../gix-trace" }
1818
gix-object = { version = "^0.38.0", path = "../gix-object" }
1919
gix-command = { version = "^0.2.10", path = "../gix-command" }
2020
gix-quote = { version = "^0.4.7", path = "../gix-quote" }
21+
gix-utils = { version = "^0.1.5", path = "../gix-utils" }
2122
gix-path = { version = "^0.10.0", path = "../gix-path" }
2223
gix-packetline = { package = "gix-packetline-blocking", version = "^0.16.6", path = "../gix-packetline-blocking" }
2324
gix-attributes = { version = "^0.20.0", path = "../gix-attributes" }

gix-filter/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct Pipeline {
4343
/// State needed to keep running filter processes.
4444
processes: driver::State,
4545
/// A utility to handle multiple buffers to keep results of various filters.
46-
bufs: pipeline::util::Buffers,
46+
bufs: gix_utils::Buffers,
4747
}
4848

4949
/// A declaration of a driver program.

gix-filter/src/pipeline/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl Pipeline {
190190
self.options.eol_config,
191191
)?;
192192

193-
let mut bufs = self.bufs.with_src(src);
193+
let mut bufs = self.bufs.use_foreign_src(src);
194194
let (src, dest) = bufs.src_and_dest();
195195
if apply_ident_filter && ident::apply(src, self.options.object_hash, dest) {
196196
bufs.swap();

gix-filter/src/pipeline/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,3 @@ impl Pipeline {
114114
pub mod convert;
115115

116116
pub(crate) mod util;
117-
118-
#[cfg(test)]
119-
mod tests;

gix-filter/src/pipeline/tests.rs

Lines changed: 0 additions & 39 deletions
This file was deleted.

gix-filter/src/pipeline/util.rs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,6 @@ use crate::{
1111
Driver,
1212
};
1313

14-
/// A utility to do buffer-swapping with.
15-
#[derive(Default, Clone)]
16-
pub(crate) struct Buffers {
17-
pub src: Vec<u8>,
18-
pub dest: Vec<u8>,
19-
}
20-
21-
/// A utility to do buffer-swapping with.
22-
pub(crate) struct BuffersWithSource<'src, 'bufs> {
23-
pub ro_src: Option<&'src [u8]>,
24-
pub src: &'bufs mut Vec<u8>,
25-
pub dest: &'bufs mut Vec<u8>,
26-
}
27-
28-
impl Buffers {
29-
pub fn with_src<'a, 'src>(&'a mut self, src: &'src [u8]) -> BuffersWithSource<'src, 'a> {
30-
self.clear();
31-
BuffersWithSource {
32-
ro_src: Some(src),
33-
src: &mut self.src,
34-
dest: &mut self.dest,
35-
}
36-
}
37-
pub fn clear(&mut self) {
38-
self.src.clear();
39-
self.dest.clear();
40-
}
41-
42-
pub fn swap(&mut self) {
43-
std::mem::swap(&mut self.src, &mut self.dest);
44-
}
45-
}
46-
47-
impl BuffersWithSource<'_, '_> {
48-
/// Must be called after every change (i.e. when it's known that `dest` was written.
49-
pub fn swap(&mut self) {
50-
self.ro_src.take();
51-
std::mem::swap(&mut self.src, &mut self.dest);
52-
self.dest.clear();
53-
}
54-
pub fn src_and_dest(&mut self) -> (&[u8], &mut Vec<u8>) {
55-
match self.ro_src {
56-
Some(src) => (src, &mut self.dest),
57-
None => (self.src, &mut self.dest),
58-
}
59-
}
60-
}
61-
6214
pub(crate) struct Configuration<'a> {
6315
pub(crate) driver: Option<&'a Driver>,
6416
/// What attributes say about CRLF handling.

0 commit comments

Comments
 (0)