[Pkg-acpi-devel] Bug#593996: acpi-support: resource waste; unnecessary forks and pipes

Michael Meskes meskes at debian.org
Mon Nov 15 13:22:31 UTC 2010


On Sun, Aug 22, 2010 at 11:39:02PM +0200, Cristian Ionescu-Idbohrn wrote:
> This is one example:
> 
> lib/device-funcs:6:    bios_version=`cat /sys/class/dmi/id/bios_version|sed -e 's/ *$//'`
> 
> Save a fork and a pipe by simply:
> 
> bios_version=$(sed -re 's/[[:blank:]]+*$//' /sys/class/dmi/id/bios_version)

Is there a reason for changing the sed expression, too? 

> This is the 3rd:
> 
> lib/state-funcs:5:WLAN_RFKILLS=`for RFKILL in /sys/class/rfkill/rfkill*; do if [ $(cat $RFKILL/type) = wlan ]; then echo $RFKILL/state; fi; done`
> 
> vs. (builtin 'read' is some 30x faster than a 'cat' fork):
> 
> WLAN_RFKILLS=$(for RFKILL in /sys/class/rfkill/rfkill*; do
> 			read rfk <$RFKILL >/dev/null || :
> 			[ "$rfk" != wlan ] || echo $RFKILL/state
> 		done)

I take it you lost "/type" in this change right?


> Similar examples can be found in a lot of other places.

So feel free to send a patch.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL





More information about the Pkg-acpi-devel mailing list