sensord: Avoid strcat
PATCH 3/3 sensord: Avoid strcat
Calling strcat twice in a row is inefficient, it's better to use sprintf at the end of the string, so that we look for that end only once.
--- prog/sensord/sense.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
prog/sensord/sense.c +2 -4
@@ -114,10 +114,8 @@ static int do_features(const sensors_chiif (feature->rrd) {const char *rrded = feature->rrd (val); -/* FIXME: Jean's review comment: -* sprintf would me more efficient. -*/ -strcat (strcat (rrdBuff,":" ), rrded ? rrded :"U" ); +sprintf (rrdBuff +strlen (rrdBuff),":%s" , + rrded ? rrded :"U" ); }return 0 ;
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors