Re: [PATCH v2 00/10] send-email: various optimizations to speed up by >2x
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- May 28, 2021, 15:49 UTC
- Message-ID
- <60b11101e5288_50514208b4@natae.notmuch>
- In-Reply-To
- <875yzcpo52.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason wrote:
Show 6 quoted lines
> Returning a flattened list is idiomatic in Perl, it means that a caller > can do any of: > > # I only care about the last value for a key, or only about > # existence checks > my %hash = func();
I was staying on the sideline because I don't know what's idiomatic in Perl, but Perl and Ruby share a lot in common (one could say Perl is the grandfather of Ruby), and I do know very well what's idiomatic in Ruby.
In perl you can do $ENV{'USER'}, and: while (my ($k, $v) = each %ENV) {
print "$k = $v\n";
}Obviously it's idiomatic to use hashes this way [1].
It was a waste for Git::config_regexp to not do the sensible thing here.
You can do exactly the same in Ruby: ENV['USER']
ENV.each { |k, v| print "#{k} = #{v}\n" }And the way I would parse these configurations in Ruby is something like:
c = `git config -l -z`.split("\0").map { |e| e.split("\n") }.to_h
c['sendemail.smtpserver']And this just gave me an idea...
[1] https://perldoc.perl.org/functions/each
-- Felipe Contreras