Re: [PATCH v4 2/7] remote-mediawiki: allow fetching namespaces with spaces

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

 



On Mon, Nov 06, 2017 at 04:19:48PM -0500, Antoine Beaupré wrote:
> From: Ingo Ruhnke <grumbel@xxxxxxxxx>
> 
> we still want to use spaces as separators in the config, but we should
> allow the user to specify namespaces with spaces, so we use underscore
> for this.
> 
> Reviewed-by: Antoine Beaupré <anarcat@xxxxxxxxxx>
> Signed-off-by: Antoine Beaupré <anarcat@xxxxxxxxxx>
> ---
>  contrib/mw-to-git/git-remote-mediawiki.perl | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
> index 5ffb57595..a1d783789 100755
> --- a/contrib/mw-to-git/git-remote-mediawiki.perl
> +++ b/contrib/mw-to-git/git-remote-mediawiki.perl
> @@ -65,6 +65,7 @@ chomp(@tracked_categories);
>  
>  # Just like @tracked_categories, but for MediaWiki namespaces.
>  my @tracked_namespaces = split(/[ \n]/, run_git("config --get-all remote.${remotename}.namespaces"));
> +for (@tracked_namespaces) { s/_/ /g; }
>  chomp(@tracked_namespaces);

Depending on the number if namespaces returned, it might be easier to convert
this to the following:

    my @tracked_namespaces = map {
    	chomp; s/_/ /g; $_;
    } split(/[ \n]/, run_git("config --get-all remote.${remotename}.namespaces"));

This would, once again, avoid creating @tracked_namespaces, and iterating over
it.

Note that this isn't about trying to 'golf' this; it's a performance
consideration.

Kindly,
Thomas Adam



[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