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.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6027 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2012-03-06 07:24:42 +00:00
1 parent 1c20f6a298
commit 38158e4fe3
2 files changed
+3 -4

No files matched your search

+1
View File
@@ -5,6 +5,7 @@ SVN HEAD
libsensors: Added support for new sysfs attributes
Change sysfs detection to survive upcoming kernel changes
sensord: Fix memory leaks revealed by valgrind
Minor performance improvements
sensors: Added support for new sysfs attributes
Display both instantaneous and average power if available.
Report thermal sensor type 1 as CPU diode
+2 -4
View File
@@ -114,10 +114,8 @@ static int do_features(const sensors_chip_name *chip,
if (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;