mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 14:53:06 +02:00
micro-optimization: sorted() can take any iterable and returns a list
So there is no need to convert everything to lists before and after. Also, all_formats is immediately converted to a set, and kept that way, so it does not need to always be accessed as set(all_formats).
This commit is contained in:
parent
04a37cdf3b
commit
c9f8ffedb1
1 changed files with 3 additions and 3 deletions
|
|
@ -35,11 +35,11 @@ def __init__(self, settings, all_formats, supports_subdirs,
|
|||
except TypeError:
|
||||
self.device_name = getattr(device, 'gui_name', None) or _('Device')
|
||||
if device.USER_CAN_ADD_NEW_FORMATS:
|
||||
all_formats = set(all_formats) | set(BOOK_EXTENSIONS)
|
||||
all_formats = all_formats | set(BOOK_EXTENSIONS)
|
||||
|
||||
format_map = settings.format_map
|
||||
disabled_formats = list(set(all_formats).difference(format_map))
|
||||
for format in format_map + list(sorted(disabled_formats)):
|
||||
disabled_formats = all_formats.difference(format_map)
|
||||
for format in format_map + sorted(disabled_formats):
|
||||
item = QListWidgetItem(format, self.columns)
|
||||
item.setData(Qt.UserRole, (format))
|
||||
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
|
||||
|
|
|
|||
Loading…
Reference in a new issue