Remove recursion in at_insert()

This commit is contained in:
Jody Bruchon 2020-09-17 15:08:33 -04:00
parent a5029645ae
commit 1de7ea76f8
1 changed files with 27 additions and 12 deletions

View File

@ -120,19 +120,31 @@ class ArchiveTree(object):
self.line = line self.line = line
def at_insert(self, line): def at_insert(self, line):
if self.line: # print("at_insert: ", line)
if line < self.line: cur = self
if self.left is None: while True:
self.left = ArchiveTree(line) # print("comparing ", line, cur.line)
if cur.line:
if line < cur.line:
if cur.left is None:
cur.left = ArchiveTree(line)
return
else:
cur = cur.left
continue
elif line > cur.line:
if cur.right is None:
cur.right = ArchiveTree(line)
return
else:
cur = cur.right
continue
else: else:
self.left.at_insert(line) # Duplicate line found
elif line > self.line: return
if self.right is None: else:
self.right = ArchiveTree(line) cur.line = line
else: return
self.right.at_insert(line)
else:
self.line = line
def at_exist(self, line): def at_exist(self, line):
if self.line is None: if self.line is None:
@ -417,6 +429,9 @@ class YoutubeDL(object):
return True return True
return False return False
if self.params.get('verbose'):
self.to_stdout('[debug] Loading archive file %r' % self.params.get('download_archive'))
preload_download_archive(self) preload_download_archive(self)
if check_deprecated('cn_verification_proxy', '--cn-verification-proxy', '--geo-verification-proxy'): if check_deprecated('cn_verification_proxy', '--cn-verification-proxy', '--geo-verification-proxy'):