From dade9db58673d4f712ba5c50ed66d1c67a7e1d5d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 7 Jul 2019 07:40:24 -0400 Subject: Avoid useless or redundant db operations. Faster. Moving operations into the "with self._connect" means less opening and closing of the database. Returning early if there is no data to write avoids writing empty contexts. --- coverage/control.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'coverage/control.py') diff --git a/coverage/control.py b/coverage/control.py index a4e21295..1001a8d6 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -648,8 +648,9 @@ class Coverage(object): self._warn("No data was collected.", slug="no-data-collected") # Find files that were never executed at all. - for file_path, plugin_name in self._inorout.find_unexecuted_files(): - self._data.touch_file(file_path, plugin_name) + if self._data: + for file_path, plugin_name in self._inorout.find_unexecuted_files(): + self._data.touch_file(file_path, plugin_name) if self.config.note: self._data.add_run_info(note=self.config.note) -- cgit v1.2.1