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

Philippe Mathieu-Daudé philmd at redhat.com
Sat Jun 15 06:22:23 UTC 2019


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 at 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 at redhat.com>




More information about the Patchew-devel mailing list