Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added small optimization to downcast_plugins
- Loading branch information
Showing
1 changed file
with
3 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,12 +147,14 @@ def downcast_plugins(plugins, | |
placeholders=None, request=None): | ||
plugin_types_map = defaultdict(list) | ||
plugin_lookup = {} | ||
plugin_ids = [] | ||
|
||
# make a map of plugin types, needed later for downcasting | ||
for plugin in plugins: | ||
plugin_types_map[plugin.plugin_type].append(plugin.pk) | ||
|
||
# Keep track of the plugin ids we've received | ||
plugin_ids = list(plugin_types_map.values()) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
piotrjakimiak
Contributor
|
||
|
||
placeholders = placeholders or [] | ||
placeholders_by_id = {placeholder.pk: placeholder for placeholder in placeholders} | ||
|
||
|
@@ -161,9 +163,6 @@ def downcast_plugins(plugins, | |
# get all the plugins of type cls.model | ||
plugin_qs = cls.get_render_queryset().filter(pk__in=pks) | ||
|
||
# Keep track of the plugin ids we've received | ||
plugin_ids.extend(plugin_ids) | ||
|
||
# put them in a map so we can replace the base CMSPlugins with their | ||
# downcasted versions | ||
for instance in plugin_qs.iterator(): | ||
|
Is it list of ids or list of list of ids?