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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
StandardDirectory.cxx
src/fs/StandardDirectory.cxx
+9
-7
No files found.
src/fs/StandardDirectory.cxx
View file @
17b316b9
...
@@ -125,8 +125,8 @@ static AllocatedPath GetStandardDir(int folder_id)
...
@@ -125,8 +125,8 @@ static AllocatedPath GetStandardDir(int folder_id)
static
const
char
home_prefix
[]
=
"$HOME/"
;
static
const
char
home_prefix
[]
=
"$HOME/"
;
static
bool
ParseConfigLine
(
const
char
*
line
,
const
char
*
dir_name
,
static
bool
AllocatedPath
&
result_dir
)
ParseConfigLine
(
char
*
line
,
const
char
*
dir_name
,
AllocatedPath
&
result_dir
)
{
{
// strip leading white space
// strip leading white space
line
=
strchug_fast
(
line
);
line
=
strchug_fast
(
line
);
...
@@ -162,7 +162,7 @@ static bool ParseConfigLine(const char *line, const char *dir_name,
...
@@ -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
// find end of the string
if
(
quoted
)
{
if
(
quoted
)
{
line_end
=
strrchr
(
line
,
'"'
);
line_end
=
strrchr
(
line
,
'"'
);
...
@@ -178,17 +178,19 @@ static bool ParseConfigLine(const char *line, const char *dir_name,
...
@@ -178,17 +178,19 @@ static bool ParseConfigLine(const char *line, const char *dir_name,
if
(
line
==
line_end
)
if
(
line
==
line_end
)
return
true
;
return
true
;
*
line_end
=
0
;
// build the result path
// build the result path
std
::
string
path
(
line
,
line_end
)
;
const
char
*
path
=
line
;
auto
result
=
AllocatedPath
::
Null
();
auto
result
=
AllocatedPath
::
Null
();
if
(
home_relative
)
{
if
(
home_relative
)
{
auto
home
=
GetHomeDir
();
auto
home
=
GetHomeDir
();
if
(
home
.
IsNull
())
if
(
home
.
IsNull
())
return
true
;
return
true
;
result
=
AllocatedPath
::
Build
(
home
,
path
.
c_str
()
);
result
=
AllocatedPath
::
Build
(
home
,
path
);
}
else
{
}
else
{
result
=
AllocatedPath
::
FromFS
(
std
::
move
(
path
)
);
result
=
AllocatedPath
::
FromFS
(
path
);
}
}
if
(
IsValidDir
(
result
.
c_str
()))
{
if
(
IsValidDir
(
result
.
c_str
()))
{
...
@@ -208,7 +210,7 @@ static AllocatedPath GetUserDir(const char *name)
...
@@ -208,7 +210,7 @@ static AllocatedPath GetUserDir(const char *name)
TextFile
input
(
dirs_file
);
TextFile
input
(
dirs_file
);
if
(
input
.
HasFailed
())
if
(
input
.
HasFailed
())
return
result
;
return
result
;
c
onst
c
har
*
line
;
char
*
line
;
while
((
line
=
input
.
ReadLine
())
!=
nullptr
)
while
((
line
=
input
.
ReadLine
())
!=
nullptr
)
if
(
ParseConfigLine
(
line
,
name
,
result
))
if
(
ParseConfigLine
(
line
,
name
,
result
))
return
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