[Patchew-devel] [PATCH] do not go through each updated series many times

Paolo Bonzini posted 1 patch 2 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20190613122804.5046-1-pbonzini@redhat.com
api/models.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[Patchew-devel] [PATCH] do not go through each updated series many times
Posted by Paolo Bonzini 2 years, 11 months ago
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