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
57729683
Commit
57729683
authored
Jul 18, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/Data: pass new items by rvalue reference
parent
9ff2606b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
17 deletions
+13
-17
Data.cxx
src/config/Data.cxx
+6
-6
Data.hxx
src/config/Data.hxx
+2
-4
File.cxx
src/config/File.cxx
+5
-7
No files found.
src/config/Data.cxx
View file @
57729683
...
...
@@ -56,9 +56,9 @@ Append(std::forward_list<T> &list, T &&src)
void
ConfigData
::
AddParam
(
ConfigOption
option
,
std
::
unique_ptr
<
ConfigParam
>
param
)
noexcept
ConfigParam
&&
param
)
noexcept
{
Append
(
GetParamList
(
option
),
std
::
move
(
*
param
));
Append
(
GetParamList
(
option
),
std
::
move
(
param
));
}
const
char
*
...
...
@@ -144,9 +144,9 @@ ConfigData::GetBool(ConfigOption option, bool default_value) const
ConfigBlock
&
ConfigData
::
AddBlock
(
ConfigBlockOption
option
,
std
::
unique_ptr
<
ConfigBlock
>
block
)
noexcept
ConfigBlock
&&
block
)
noexcept
{
return
*
Append
(
GetBlockList
(
option
),
std
::
move
(
*
block
));
return
*
Append
(
GetBlockList
(
option
),
std
::
move
(
block
));
}
const
ConfigBlock
*
...
...
@@ -172,8 +172,8 @@ ConfigData::MakeBlock(ConfigBlockOption option,
{
auto
*
block
=
const_cast
<
ConfigBlock
*>
(
FindBlock
(
option
,
key
,
value
));
if
(
block
==
nullptr
)
{
auto
new_block
=
std
::
make_unique
<
ConfigBlock
>
()
;
new_block
->
AddBlockParam
(
key
,
value
);
ConfigBlock
new_block
;
new_block
.
AddBlockParam
(
key
,
value
);
block
=
&
AddBlock
(
option
,
std
::
move
(
new_block
));
}
...
...
src/config/Data.hxx
View file @
57729683
...
...
@@ -27,7 +27,6 @@
#include <array>
#include <chrono>
#include <forward_list>
#include <memory>
struct
ConfigParam
;
struct
ConfigBlock
;
...
...
@@ -47,8 +46,7 @@ struct ConfigData {
return
params
[
size_t
(
option
)];
}
void
AddParam
(
ConfigOption
option
,
std
::
unique_ptr
<
ConfigParam
>
param
)
noexcept
;
void
AddParam
(
ConfigOption
option
,
ConfigParam
&&
param
)
noexcept
;
gcc_pure
const
ConfigParam
*
GetParam
(
ConfigOption
option
)
const
noexcept
{
...
...
@@ -102,7 +100,7 @@ struct ConfigData {
}
ConfigBlock
&
AddBlock
(
ConfigBlockOption
option
,
std
::
unique_ptr
<
ConfigBlock
>
block
)
noexcept
;
ConfigBlock
&&
block
)
noexcept
;
gcc_pure
const
ConfigBlock
*
GetBlock
(
ConfigBlockOption
option
)
const
noexcept
{
...
...
src/config/File.cxx
View file @
57729683
...
...
@@ -32,8 +32,6 @@
#include "fs/io/BufferedReader.hxx"
#include "Log.hxx"
#include <memory>
#include <assert.h>
static
constexpr
char
CONF_COMMENT
=
'#'
;
...
...
@@ -74,10 +72,10 @@ config_read_name_value(ConfigBlock &block, char *input, unsigned line)
block
.
AddBlockParam
(
name
,
std
::
move
(
value
),
line
);
}
static
std
::
unique_ptr
<
ConfigBlock
>
static
ConfigBlock
config_read_block
(
BufferedReader
&
reader
)
{
std
::
unique_ptr
<
ConfigBlock
>
block
(
new
ConfigBlock
(
reader
.
GetLineNumber
()
));
ConfigBlock
block
(
reader
.
GetLineNumber
(
));
while
(
true
)
{
char
*
line
=
reader
.
ReadLine
();
...
...
@@ -101,7 +99,7 @@ config_read_block(BufferedReader &reader)
/* parse name and value */
config_read_name_value
(
*
block
,
line
,
config_read_name_value
(
block
,
line
,
reader
.
GetLineNumber
());
}
}
...
...
@@ -150,8 +148,8 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
/* now parse the block or the value */
config_data
.
AddParam
(
o
,
std
::
make_unique
<
ConfigParam
>
(
ExpectValueAndEnd
(
tokenizer
),
reader
.
GetLineNumber
()));
config_data
.
AddParam
(
o
,
ConfigParam
(
ExpectValueAndEnd
(
tokenizer
),
reader
.
GetLineNumber
()));
}
static
void
...
...
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