diff options
author | Jody Bruchon <jody@jodybruchon.com> | 2020-09-17 15:08:33 -0400 |
---|---|---|
committer | Jody Bruchon <jody@jodybruchon.com> | 2020-09-17 15:08:33 -0400 |
commit | 1de7ea76f8d12d301759ab7c193eb71bcbcd6a1d (patch) | |
tree | 54f1470bb7e124716bcf6b215a0558b5159a7442 | |
parent | a5029645aed1557ab6bf4cde3e70e10fc9917693 (diff) | |
download | hypervideo-pre-1de7ea76f8d12d301759ab7c193eb71bcbcd6a1d.tar.lz hypervideo-pre-1de7ea76f8d12d301759ab7c193eb71bcbcd6a1d.tar.xz hypervideo-pre-1de7ea76f8d12d301759ab7c193eb71bcbcd6a1d.zip |
Remove recursion in at_insert()
-rw-r--r-- | youtube_dlc/YoutubeDL.py | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/youtube_dlc/YoutubeDL.py b/youtube_dlc/YoutubeDL.py index dbf8915d0..bae42bf37 100644 --- a/youtube_dlc/YoutubeDL.py +++ b/youtube_dlc/YoutubeDL.py @@ -120,19 +120,31 @@ class ArchiveTree(object): self.line = line def at_insert(self, line): - if self.line: - if line < self.line: - if self.left is None: - self.left = ArchiveTree(line) - else: - self.left.at_insert(line) - elif line > self.line: - if self.right is None: - self.right = ArchiveTree(line) +# print("at_insert: ", line) + cur = self + while True: +# 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: - self.right.at_insert(line) - else: - self.line = line + # Duplicate line found + return + else: + cur.line = line + return def at_exist(self, line): if self.line is None: @@ -417,6 +429,9 @@ class YoutubeDL(object): return True return False + if self.params.get('verbose'): + self.to_stdout('[debug] Loading archive file %r' % self.params.get('download_archive')) + preload_download_archive(self) if check_deprecated('cn_verification_proxy', '--cn-verification-proxy', '--geo-verification-proxy'): |