Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a runtime comparison #36

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Remove a runtime comparison

There is no need to check every single time
if the corpus has been initialized: we can just add
the dummy `bytearray(0)` value at startup, and assume
that the corpus will never be empty.
  • Loading branch information
jvoisin committed Feb 12, 2020
commit 88a808a72e82b97508140724140ad9ffd1eb2095
@@ -409,6 +409,10 @@ def __init__(self, dirs=None, max_input_size=4096, mutators_filter=None, dict_pa
fname = os.path.join(path, i)
if os.path.isfile(fname):
self._add_file(fname)

if not self._inputs:
self.put(bytearray(0))

self._seed_run_finished = not self._inputs
self._seed_idx = 0
self._save_corpus = dirs and os.path.isdir(dirs[0])
@@ -488,13 +492,8 @@ def generate_input(self):
self._seed_run_finished = True
return next_input

if len(self._inputs) == 0:
zero_test_case = bytearray(0)
self.put(zero_test_case)
return zero_test_case
else:
buf = self._inputs[self._rand(len(self._inputs))]
return self.mutate(buf)
buf = self._inputs[self._rand(len(self._inputs))]
return self.mutate(buf)

def mutate(self, buf):
res = buf[:]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.