zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Peter Stephenson <pws@ibmth.df.unipi.it>,
	zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: PATCH: 3.1.4: autocd to directory in $PATH
Date: Fri, 9 Oct 1998 10:16:01 -0700	[thread overview]
Message-ID: <981009101601.ZM25272@candle.brasslantern.com> (raw)
In-Reply-To: <9810031530.AA20041@ibmth.df.unipi.it>

On Oct 3,  5:30pm, Peter Stephenson wrote:
} Subject: PATCH: 3.1.4: autocd to directory in $PATH
}
} at the moment it looks to me like nothing other than the full
} stat() horror would be a really worthwhile improvement on
[...]
} ***************
} *** 1489,1494 ****
} --- 1502,1509 ----
}   	    char *cmdarg = (char *) peekfirst(args);
}   
}   	    hn = cmdnamtab->getnode(cmdnamtab, cmdarg);
} + 	    if (hn && !isreallycom((Cmdnam)hn))
} + 		hn = NULL;
}   	    if (!hn && isset(HASHCMDS) && strcmp(cmdarg, "..")) {
}   		for (s = cmdarg; *s && *s != '/'; s++);
}   		if (!*s)
		    hn = (HashNode) hashcmd(cmdarg, pathchecked);

(One more line of context added for clarity.)

I haven't actually walked through this with a debugger, but it looks to
me as though hn = NULL at that point is going to trigger the call to
hashcmd(cmdarg, pathchecked), which in turn is going to call iscom() a
second time; so you end up stat()ing the directory twice.  Perhaps

 	    if (hn && !isreallycom((Cmdnam)hn))
 		hn = NULL;
 	    else if (!hn && isset(HASHCMDS) && strcmp(cmdarg, "..")) {
            ^^^^
would be better?

Also, what about removing the improperly hashed directory from cmdnamtab
once you've discovered that it isn't a command?  That would (I think) get
any real command with the same name put into the table the next time that
name was used, so that you'll never needlessly stat() again.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1998-10-09 17:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-03 15:30 Peter Stephenson
1998-10-09 17:16 ` Bart Schaefer [this message]
1998-10-12 12:18   ` PATCH: 3.1.4: autocd to directory in $PATH (2) Peter Stephenson
1998-10-14 19:07     ` PATCH: " Bart Schaefer

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=981009101601.ZM25272@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@math.gatech.edu \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).