On Thu, Oct 20, 2011 at 04:59:40PM +0200, Thomas Funk wrote:
> -----Urspr√ľngliche Nachricht-----
> Von: "Thomas Adam" <tho...@fvwm.org>
> Gesendet: 20.10.2011 15:00:58
> An: "Thomas Funk" <t.f...@web.de>
> Betreff: Re: Reworked fvwm-menu-desktop
> 
> >Some very quick observations...
> 
> >+my $xdg_data_home = $ENV{XDG_DATA_HOME} || "$ENV{HOME}/.local/share";
> >+my $xdg_menu_prefix = $ENV{XDG_MENU_PREFIX} || '';
> >+my %xdg_menus;
> > my @PATH_DIRS = split(':',$ENV{PATH}); # for checking if applications exist
> 
> >Why?
> because it's follows the xdg spec.

No, this was in reference to a blank line, which had no reason being there
(yes, I am picky.)

> because it's a command line variable? I thought I need it. It's like the same
> as with $kde_cmd. Or not?

Same reason as above -- a blank line.  Why?

> I sort it because an empty key ('' = applications.menu) should start first.
> But I see, in this case it is useless.

A key of '' is a bug, not a feature.  :)

> >Can you not sort %xdg_menus once, or better yet Tie it?
> I red often that hash keys cannot sorted. They will be written
> randomly into the hash structure. So, therefore I sort them ever i need it ...

Yes, hash lookups are not ordered, but it wasn't that which I was asking, it
was why the need to sort at all, and why do it where it's needed?

> >+sub create_fvwm2_menu_hash {
> >+ my $menu = shift;
> >+ my %new_menu = ();
> >+ my @reference_menu = split("\n", $menu);
> >+ # first create menu hashes
> >+ foreach my $line (@reference_menu) {
> >+ if ($line =~ m/^DestroyMenu \"(.*)\"/) {
> >+ $new_menu{$1} = ();
> >+ }
> >+ }
> >
> >my %new_menu = map {
> > /^DestroyMenu \"(.*)\"/ and $1 => ''
> >} split("\n", $menu);
> 
> >Assigning an empty list literal as you've done is meaningless in this
> >context.
> I thought pattern matching is faster than working with substrings :S

No -- firing up the regexp engine is expensive on items where substr() is
more useful, no matter now tempting it is to do otherwise.  Especially for
interpolated content which is generally set once and then never changes.

-- Thomas Adam

Reply via email to