Re: [PATCH v2 00/10] send-email: various optimizations to speed up by >2x

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ævar Arnfjörð Bjarmason wrote:
> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux