Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add ability to require that the hole sides be ordered or the hole sid…

…e be under a specified maximum.
  • Loading branch information...
commit fed7950236474c3b5cc33b014873e3dbc09db1d9 1 parent dd329e9
@jjwhitney authored
Showing with 11 additions and 8 deletions.
  1. +1 −1  src/bdelta.cpp
  2. +1 −1  src/bdelta.h
  3. +9 −6 src/libbdelta.cpp
View
2  src/bdelta.cpp
@@ -26,7 +26,7 @@ void *f_read(void *f, void *buf, unsigned place, unsigned num) {
}
void my_pass(BDelta_Instance *b, unsigned blocksize, unsigned minMatchSize, unsigned flags) {
- bdelta_pass(b, blocksize, minMatchSize, flags);
+ bdelta_pass(b, blocksize, minMatchSize, 0, flags);
bdelta_clean_matches(b, BDELTA_REMOVE_OVERLAP);
}
View
2  src/bdelta.h
@@ -29,7 +29,7 @@ BDelta_Instance *bdelta_init_alg(unsigned data1_size, unsigned data2_size,
unsigned tokenSize);
void bdelta_done_alg(BDelta_Instance *b);
-void bdelta_pass(BDelta_Instance *b, unsigned blockSize, unsigned minMatchSize, unsigned flags);
+void bdelta_pass(BDelta_Instance *b, unsigned blockSize, unsigned minMatchSize, unsigned maxHoleSize, unsigned flags);
void bdelta_swap_inputs(BDelta_Instance *b);
void bdelta_clean_matches(BDelta_Instance *b, unsigned flags);
View
15 src/libbdelta.cpp
@@ -390,7 +390,7 @@ void get_unused_blocks(UnusedRange *unused, unsigned *numunusedptr) {
}
}
-void bdelta_pass(BDelta_Instance *b, unsigned blocksize, unsigned minMatchSize, unsigned flags) {
+void bdelta_pass(BDelta_Instance *b, unsigned blocksize, unsigned minMatchSize, unsigned maxHoleSize, unsigned flags) {
// Trick for including the free range at the end.
b->matches.push_back(Match(b->data1_size, b->data2_size, 0));
@@ -412,11 +412,14 @@ void bdelta_pass(BDelta_Instance *b, unsigned blocksize, unsigned minMatchSize,
if (flags & BDELTA_LOCAL) {
std::sort(unused, unused + numunused, comparemrp2);
- for (unsigned i = 0; i < numunused; ++i)
- if (unused[i].num >= blocksize && unused2[i].num >= blocksize)
- bdelta_pass_2(b, blocksize, minMatchSize, unused + i, 1, unused2 + i, 1);
- }
- else
+ for (unsigned i = 0; i < numunused; ++i) {
+ UnusedRange u1 = unused[i], u2 = unused2[i];
+ if (u1.num >= blocksize && u2.num >= blocksize)
+ if (! maxHoleSize || (u1.num <= maxHoleSize && u2.num <= maxHoleSize))
+ if (! (flags & BDELTA_SIDES_ORDERED) || (next(u1.ml) == u1.mr))
+ bdelta_pass_2(b, blocksize, minMatchSize, &u1, 1, &u2, 1);
+ }
+ } else
bdelta_pass_2(b, blocksize, minMatchSize, unused, numunused, unused2, numunused2);
if (verbose) printf("pass (blocksize: %d, matches: %zu)\n", blocksize, b->matches.size());
Please sign in to comment.
Something went wrong with that request. Please try again.