cvs commit: src/etc/rc.d mixer

John Baldwin jhb at FreeBSD.org
Tue Apr 6 11:39:07 PDT 2004


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 at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the cvs-src mailing list