emory: add minimum chunk size parameter

This commit is contained in:
Danny Robson 2019-04-23 09:35:45 +10:00
parent f6840ba6c1
commit 51371bf3bd

View File

@ -33,6 +33,7 @@ enum {
ARG_SELF, ARG_SELF,
ARG_BITS, ARG_BITS,
ARG_WINDOW, ARG_WINDOW,
ARGS_MINIMUM,
ARGS_INPUT, ARGS_INPUT,
NUM_ARGS, NUM_ARGS,
@ -42,12 +43,13 @@ enum {
int main (int argc, char const **argv) int main (int argc, char const **argv)
{ {
if (argc != NUM_ARGS) { if (argc != NUM_ARGS) {
std::cerr << "usage: " << argv[ARG_SELF] << " <bits> <window> <input>\n"; std::cerr << "usage: " << argv[ARG_SELF] << " <bits> <window> <minimum> <input>\n";
return EXIT_FAILURE; return EXIT_FAILURE;
} }
auto const window = cruft::parse::from_string<std::size_t> (argv[ARG_WINDOW]); auto const window = cruft::parse::from_string<std::size_t> (argv[ARG_WINDOW]);
auto const bits = cruft::parse::from_string<std::size_t> (argv[ARG_BITS ]); auto const bits = cruft::parse::from_string<std::size_t> (argv[ARG_BITS ]);
auto const minimum_size = cruft::parse::from_string<std::ptrdiff_t> (argv[ARGS_MINIMUM]);
cruft::mapped_file src (argv[ARGS_INPUT]); cruft::mapped_file src (argv[ARGS_INPUT]);
cruft::view bytes (src); cruft::view bytes (src);
@ -64,7 +66,10 @@ int main (int argc, char const **argv)
for (u08 const *cursor = bytes.begin (), *start = src.data (); cursor != bytes.end (); cursor++) { for (u08 const *cursor = bytes.begin (), *start = src.data (); cursor != bytes.end (); cursor++) {
auto const res = h (cursor); auto const res = h (cursor);
if (res & mask) if (std::distance (start, cursor) < minimum_size)
continue;
if (unlikely (res & mask))
continue; continue;
cruft::view<u08 const*> const region { start, cursor }; cruft::view<u08 const*> const region { start, cursor };