diff options
author | Sergey Senozhatsky <sergey.senozhatsky@gmail.com> | 2011-05-06 19:40:52 +0300 |
---|---|---|
committer | Arjan van de Ven <arjan@linux.intel.com> | 2011-05-11 00:04:24 -0400 |
commit | 40cdd6d7094fc1919c82f77d633410cef1604576 (patch) | |
tree | 634e4b60e9cf89dc0a2289db66a6daf0989c5320 | |
parent | 0b13635f9a6824510a6f4bdadeecf06aef616281 (diff) | |
download | powertop-40cdd6d7094fc1919c82f77d633410cef1604576.tar.gz |
lib: style: Pass const references of std::string
(Sorry, resend. Forget to fill the subject line properly).
lib: Pass const references of std::string, avoiding temporary object
creation.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
-rw-r--r-- | lib.cpp | 7 | ||||
-rw-r--r-- | lib.h | 6 |
2 files changed, 6 insertions, 7 deletions
@@ -50,7 +50,6 @@ extern "C" { #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> -#include <string.h> #include <locale.h> #include <libintl.h> #include <limits> @@ -163,7 +162,7 @@ bool stringless::operator()(const char * const & lhs, const char * const & rhs) return false; } -void write_sysfs(string filename, string value) +void write_sysfs(const string &filename, const string &value) { ofstream file; @@ -174,7 +173,7 @@ void write_sysfs(string filename, string value) file.close(); } -int read_sysfs(string filename) +int read_sysfs(const string &filename) { ifstream file; int i; @@ -187,7 +186,7 @@ int read_sysfs(string filename) return i; } -string read_sysfs_string(string filename) +string read_sysfs_string(const string &filename) { ifstream file; char content[4096]; @@ -56,9 +56,9 @@ public: #include <string> using namespace std; -extern void write_sysfs(string filename, string value); -extern int read_sysfs(string filename); -extern string read_sysfs_string(string filename); +extern void write_sysfs(const string &filename, const string &value); +extern int read_sysfs(const string &filename); +extern string read_sysfs_string(const string &filename); extern string read_sysfs_string(const char *format, const char *param); extern void format_watts(double W, char *buffer, unsigned int len); |