aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-07 15:21:19 +0200
committerMax Kellermann <max@duempel.org>2014-08-07 16:07:52 +0200
commit17b316b94bcc65ddf60fde645457f3d54e74e446 (patch)
tree57a6d1640920e2c181de41e9df43041bc552170d /src/fs
parent8921b4f9d15cb9baa0d449021992eab7853b9e02 (diff)
downloadmpd-17b316b94bcc65ddf60fde645457f3d54e74e446.tar.gz
mpd-17b316b94bcc65ddf60fde645457f3d54e74e446.tar.xz
mpd-17b316b94bcc65ddf60fde645457f3d54e74e446.zip
fs/StandardDirectory: pass writable string to ParseConfigLine()
Eliminate the std::string overhead.
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/StandardDirectory.cxx18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/fs/StandardDirectory.cxx b/src/fs/StandardDirectory.cxx
index c8cc7263e..c266480f7 100644
--- a/src/fs/StandardDirectory.cxx
+++ b/src/fs/StandardDirectory.cxx
@@ -125,8 +125,8 @@ static AllocatedPath GetStandardDir(int folder_id)
static const char home_prefix[] = "$HOME/";
-static bool ParseConfigLine(const char *line, const char *dir_name,
- AllocatedPath &result_dir)
+static bool
+ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir)
{
// strip leading white space
line = strchug_fast(line);
@@ -162,7 +162,7 @@ static bool ParseConfigLine(const char *line, const char *dir_name,
}
- const char *line_end;
+ char *line_end;
// find end of the string
if (quoted) {
line_end = strrchr(line, '"');
@@ -178,17 +178,19 @@ static bool ParseConfigLine(const char *line, const char *dir_name,
if (line == line_end)
return true;
- // build the result path
- std::string path(line, line_end);
+ *line_end = 0;
+
+ // build the result path
+ const char *path = line;
auto result = AllocatedPath::Null();
if (home_relative) {
auto home = GetHomeDir();
if (home.IsNull())
return true;
- result = AllocatedPath::Build(home, path.c_str());
+ result = AllocatedPath::Build(home, path);
} else {
- result = AllocatedPath::FromFS(std::move(path));
+ result = AllocatedPath::FromFS(path);
}
if (IsValidDir(result.c_str())) {
@@ -208,7 +210,7 @@ static AllocatedPath GetUserDir(const char *name)
TextFile input(dirs_file);
if (input.HasFailed())
return result;
- const char *line;
+ char *line;
while ((line = input.ReadLine()) != nullptr)
if (ParseConfigLine(line, name, result))
return result;