When a series consists of many patches and they are (as it almost
always happens) merged in a single batch, series_update has
quadratic complexity. Fix that by using a set.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
api/models.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/api/models.py b/api/models.py
index 81bc167..059eaeb 100644
--- a/api/models.py
+++ b/api/models.py
@@ -306,7 +306,7 @@ class Project(models.Model):
project_head = property(get_project_head, set_project_head)
def series_update(self, message_ids):
- updated_series = []
+ updated_series = set()
for msgid in message_ids:
if msgid.startswith("<") and msgid.endswith(">"):
msgid = msgid[1:-1]
@@ -319,7 +319,7 @@ class Project(models.Model):
mo.save()
s = mo.get_series_head()
if s:
- updated_series.append(s)
+ updated_series.add(s)
for series in updated_series:
for p in series.get_patches():
if not p.is_merged:
--
2.21.0
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
On 6/13/19 2:28 PM, Paolo Bonzini wrote:
> When a series consists of many patches and they are (as it almost
> always happens) merged in a single batch, series_update has
> quadratic complexity. Fix that by using a set.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> api/models.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/api/models.py b/api/models.py
> index 81bc167..059eaeb 100644
> --- a/api/models.py
> +++ b/api/models.py
> @@ -306,7 +306,7 @@ class Project(models.Model):
> project_head = property(get_project_head, set_project_head)
>
> def series_update(self, message_ids):
> - updated_series = []
> + updated_series = set()
> for msgid in message_ids:
> if msgid.startswith("<") and msgid.endswith(">"):
> msgid = msgid[1:-1]
> @@ -319,7 +319,7 @@ class Project(models.Model):
> mo.save()
> s = mo.get_series_head()
> if s:
> - updated_series.append(s)
> + updated_series.add(s)
> for series in updated_series:
> for p in series.get_patches():
> if not p.is_merged:
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
© 2016 - 2026 Red Hat, Inc.