Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
17b316b9
Commit
17b316b9
authored
Aug 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/StandardDirectory: pass writable string to ParseConfigLine()
Eliminate the std::string overhead.
parent
8921b4f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
StandardDirectory.cxx
src/fs/StandardDirectory.cxx
+10
-8
No files found.
src/fs/StandardDirectory.cxx
View file @
17b316b9
...
...
@@ -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,
}
c
onst
c
har
*
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
;
c
onst
c
har
*
line
;
char
*
line
;
while
((
line
=
input
.
ReadLine
())
!=
nullptr
)
if
(
ParseConfigLine
(
line
,
name
,
result
))
return
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment