[tor-commits] [stem/master] Short circuit 'is ignored' checks

atagar at torproject.org atagar at torproject.org
Thu Feb 23 21:28:49 UTC 2017


commit d7895db5c68bc9083ea2190d58d96f65c1c4bb1a
Author: Damian Johnson <atagar at torproject.org>
Date:   Wed Feb 22 20:04:58 2017 -0800

    Short circuit 'is ignored' checks
    
    No noticeable performance improvement, but clearly pointless iterating through
    everything.
---
 stem/util/test_tools.py | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py
index f2da36f..0d70dc7 100644
--- a/stem/util/test_tools.py
+++ b/stem/util/test_tools.py
@@ -252,9 +252,6 @@ def stylistic_issues(paths, check_newlines = False, check_exception_keyword = Fa
       import pycodestyle
 
     class StyleReport(pycodestyle.BaseReport):
-      def __init__(self, options):
-        super(StyleReport, self).__init__(options)
-
       def init_file(self, filename, lines, expected, line_offset):
         super(StyleReport, self).init_file(filename, lines, expected, line_offset)
 
@@ -373,18 +370,16 @@ def pyflakes_issues(paths):
 
         for ignored_path, ignored_issues in self._ignored_issues.items():
           if path.endswith(ignored_path):
-            is_match = issue in ignored_issues
+            if issue in ignored_issues:
+              return True
 
             for prefix in [i[:1] for i in ignored_issues if i.endswith('*')]:
               if issue.startswith(prefix):
-                is_match = True
+                return True
 
             for suffix in [i[1:] for i in ignored_issues if i.startswith('*')]:
               if issue.endswith(suffix):
-                is_match = True
-
-            if is_match:
-              return True
+                return True
 
         return False
 



More information about the tor-commits mailing list