Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Apr 2004 13:03:39 -0400
From:      John Baldwin <jhb@FreeBSD.org>
To:        Doug Barton <DougB@FreeBSD.org>
Cc:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/etc/rc.d mixer
Message-ID:  <200404061303.39729.jhb@FreeBSD.org>
In-Reply-To: <406F5748.2080603@FreeBSD.org>
References:  <200403270926.i2R9QMiP083177@repoman.freebsd.org> <200403291155.43206.jhb@FreeBSD.org> <406F5748.2080603@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 03 April 2004 07:31 pm, Doug Barton wrote:
> John Baldwin wrote:
> >>  3. Remove an unecessary function, and therefore collapse one variable.
> >
> > Only unnecessary if you don't value abstraction. :)  Now if you want to
> > ever change the names of the mixer saved files due to a conflict or some
> > such, you have to change it in multiple places rather than just one.
>
> You're right, and if there were more than just two spots, or the same
> file name was used in more than one script, it would be worth a level of
> abstraction. But since neither of those is true, (and since the file
> name is very unlikely to change), it's not worth it. Also, FYI, the way
> you did it is not the typical "Bourne shell'ish" way to abstract a file
> name. It would be much more common (and infinitely more efficient) to
> simply set a script variable with the file name, and then use that
> throughout the script.

Note that it is not a single file, but one per mixer, and that the name of the 
file is a function of the mixer device name.  :)  Also, I think arguing about 
efficiency here is probably rather moot.  This is a shell script, not an RTOS 
kernel, and it is only executed at startup/shutdown, not in a fast path.  
Also, the extra fork's are for the /bin/sh text that is already in core 
since /bin/sh is already running.  The fork's to run the mixer program are 
much more expensive than using `` to execute a shell function.  It's a minor 
thing though, and I'm perfectly happy to leave it as it is, I just don't 
think the function was "unnecessary".  Perhaps "over-generalized", but I'm 
currently very adverse to code duplication.  *shrug*

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404061303.39729.jhb>