From: Damien Leone <damien.leone@fensalir.fr>
To: sup-devel <sup-devel@rubyforge.org>
Subject: Re: [sup-devel] [PATCH] Avoid O(n^2) complexity for maildir deduplication.
Date: Sun, 13 Mar 2011 17:42:17 +0100 [thread overview]
Message-ID: <1300034524-sup-1251@mailer> (raw)
In-Reply-To: <1295563453-31049-1-git-send-email-ezyang@mit.edu>
Pushed, thanks!
Excerpts from Edward Z. Yang's message of jeu. janv. 20 23:44:13 +0100 2011:
> Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
> ---
> lib/sup/maildir.rb | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
> index ba8efed..bc30baa 100644
> --- a/lib/sup/maildir.rb
> +++ b/lib/sup/maildir.rb
> @@ -128,14 +128,16 @@ class Maildir < Source
> ## deleted arrays, meaning that its flags changed or that it has
> ## been moved, these ids need to be removed from added and deleted
> add_to_delete = del_to_delete = []
> + map = Hash.new { |hash, key| hash[key] = [] }
> + deleted.each do |id_del|
> + map[maildir_data(id_del)[0]].push id_del
> + end
> added.each do |id_add|
> - deleted.each do |id_del|
> - if maildir_data(id_add)[0] == maildir_data(id_del)[0]
> + map[maildir_data(id_add)[0]].each do |id_del|
> updated.push [ id_del, id_add ]
> add_to_delete.push id_add
> del_to_delete.push id_del
> end
> - end
> end
> added -= add_to_delete
> deleted -= del_to_delete
--
Damien Leone <damien.leone@fensalir.fr>
Web: http://dleone.fensalir.fr/
GPG: 0x82EB4DDF
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
next prev parent reply other threads:[~2011-03-13 17:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-20 22:44 Edward Z. Yang
2011-03-13 16:42 ` Damien Leone [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-01-20 2:44 Edward Z. Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1300034524-sup-1251@mailer \
--to=damien.leone@fensalir.fr \
--cc=sup-devel@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox