Skip to content

Commit 25502a2

Browse files
committed
Improve tracing, remove dead code #712
Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 9fdbac4 commit 25502a2

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/licensedcode/index.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
def logger_debug(*args):
8282
pass
8383

84-
if TRACE or TRACE_INDEXING_PERF or TRACE_QUERY_RUN_SIMPLE or os.environ.get('SCANCODE_LICENSE_DEBUG'):
84+
if (TRACE or TRACE_INDEXING_PERF or TRACE_QUERY_RUN_SIMPLE
85+
or os.environ.get('SCANCODE_LICENSE_DEBUG') or TRACE_NEGATIVE):
8586
import logging
8687

8788
logger = logging.getLogger(__name__)
@@ -262,13 +263,10 @@ def _add_rules(self, rules, _ranked_tokens=global_tokens_by_ranks):
262263
rul.rid = rid
263264

264265
# classify rules and build disjuncted sets of rids
265-
rul_len = rul.length
266266
if rul.false_positive:
267267
# false positive rules do not participate in the matches at all
268268
# they are used only in post-matching filtering
269269
self.false_positive_rids.add(rid)
270-
if rul_len > self.largest_false_positive_length:
271-
self.largest_false_positive_length = rul_len
272270
elif rul.negative:
273271
# negative rules are matched early and their exactly matched
274272
# tokens are removed from the token stream
@@ -428,7 +426,7 @@ def match(self, location=None, query_string=None, min_score=0, detect_negative=T
428426
return []
429427

430428
#######################################################################
431-
# Whole file matching: hash, negative and exact matching
429+
# Whole file matching: hash and exact matching
432430
#######################################################################
433431
whole_query_run = qry.whole_query_run()
434432
if not whole_query_run or not whole_query_run.matchables:
@@ -438,7 +436,7 @@ def match(self, location=None, query_string=None, min_score=0, detect_negative=T
438436
# hash
439437
hash_matches = match_hash.hash_match(self, whole_query_run)
440438
if hash_matches:
441-
self.debug_matches(hash_matches, '#match FINAL Hash matched', location, query_string)
439+
if TRACE: self.debug_matches(hash_matches, '#match FINAL Hash matched', location, query_string)
442440
match.set_lines(hash_matches, qry.line_by_pos)
443441
return hash_matches
444442

@@ -449,9 +447,7 @@ def match(self, location=None, query_string=None, min_score=0, detect_negative=T
449447
if TRACE: logger_debug('#match: NEGATIVE')
450448
negative_matches = self.negative_match(whole_query_run)
451449
for neg in negative_matches:
452-
if TRACE_NEGATIVE: self.debug_matches(negative_matches, ' ##match: NEGATIVE subtracting #:', location, query_string)
453450
whole_query_run.subtract(neg.qspan)
454-
if TRACE_NEGATIVE: logger_debug(' #match: NEGATIVE found', negative_matches)
455451

456452
# exact matches
457453
if TRACE_EXACT: logger_debug('#match: EXACT')
@@ -567,10 +563,8 @@ def negative_match(self, query_run):
567563
from the query run.
568564
"""
569565
matches = match_aho.exact_match(self, query_run, self.negative_automaton)
570-
566+
571567
if TRACE_NEGATIVE and matches: logger_debug(' ##final _negative_matches:....', len(matches))
572-
if TRACE_NEGATIVE and matches: map(logger_debug, matches)
573-
574568
return matches
575569

576570
def _print_index_stats(self):

0 commit comments

Comments
 (0)