-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathminimizer.py
31 lines (22 loc) · 999 Bytes
/
minimizer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from typing import List
from copy import deepcopy
from model.file_model import BaseFile
from model.model_base import Match, ScanSpeed
from scanner import Scanner
from reducer import Reducer
# Minimized existing matches
# If scanned with a large chunksize, can minimize it further
# Does not provide any performance increases tho, so currently unused
def minimizeMatches(file: BaseFile, matches: List[Match], scanner: Scanner):
newAllMatches: List[Match] = []
for match in matches:
filePlay = deepcopy(file)
# hide all other
for matchPatch in matches:
if match.fileOffset != matchPatch.fileOffset:
filePlay.Data().hideMatch(matchPatch)
reducer = Reducer(filePlay, scanner, ScanSpeed.Complete)
newMatches = reducer.scan(match.start(), match.end())
print("New matches for match {}-{} ({}):".format(match.start(), match.end(), match.size))
newAllMatches += newMatches
return newAllMatches