From cad87ea77bbfc5eb4a650a04d1b4cbd5385e641b Mon Sep 17 00:00:00 2001 From: Hollow Man Date: Tue, 4 Aug 2020 22:53:29 +0800 Subject: [PATCH] Further optimize Signed-off-by: Hollow Man --- app/pdf-viewer/buffer.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/pdf-viewer/buffer.py b/app/pdf-viewer/buffer.py index 6ff05a0..7c4725f 100755 --- a/app/pdf-viewer/buffer.py +++ b/app/pdf-viewer/buffer.py @@ -389,14 +389,15 @@ class PdfViewerWidget(QWidget): if time%2 == 1 and time//2 > 0: imagebboxlist.extend(newly_added_overlapbboxlist) - # remove duplicate to make it run faster - for item in set(imagebboxlist): - if imagebboxlist.count(item) % 2 == 0: - while item in imagebboxlist: - imagebboxlist.remove(item) - else: - while imagebboxlist.count(item) > 1: - imagebboxlist.remove(item) + if len(imagebboxlist) != len(set(imagebboxlist)): + # remove duplicate to make it run faster + for item in set(imagebboxlist): + if imagebboxlist.count(item) % 2 == 0: + while item in imagebboxlist: + imagebboxlist.remove(item) + else: + while imagebboxlist.count(item) > 1: + imagebboxlist.remove(item) for bbox in imagebboxlist: pixmap.invertIRect(bbox * self.scale)