Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
gflags
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
gflags
Commits
3c0ad4fc
Commit
3c0ad4fc
authored
Aug 01, 2016
by
dreamer.dead
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract common code from FlagRegisterer to reduce size.
parent
a1e461d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
gflags.cc
src/gflags.cc
+21
-9
No files found.
src/gflags.cc
View file @
3c0ad4fc
...
...
@@ -1440,18 +1440,30 @@ bool AddFlagValidator(const void* flag_ptr, ValidateFnProto validate_fn_proto) {
// values in a global destructor.
// --------------------------------------------------------------------
template
<
typename
FlagType
>
FlagRegisterer
::
FlagRegisterer
(
const
char
*
name
,
const
char
*
help
,
const
char
*
filename
,
FlagType
*
current_storage
,
FlagType
*
defvalue_storage
)
{
namespace
{
void
RegisterCommandLineFlag
(
const
char
*
name
,
const
char
*
help
,
const
char
*
filename
,
FlagValue
*
current
,
FlagValue
*
defvalue
)
{
if
(
help
==
NULL
)
help
=
""
;
FlagValue
*
current
=
new
FlagValue
(
current_storage
,
false
);
FlagValue
*
defvalue
=
new
FlagValue
(
defvalue_storage
,
false
);
// Importantly, flag_ will never be deleted, so storage is always good.
CommandLineFlag
*
flag
=
new
CommandLineFlag
(
name
,
help
,
filename
,
current
,
defvalue
);
FlagRegistry
::
GlobalRegistry
()
->
RegisterFlag
(
flag
);
// default registry
CommandLineFlag
*
flag
=
new
CommandLineFlag
(
name
,
help
,
filename
,
current
,
defvalue
);
FlagRegistry
::
GlobalRegistry
()
->
RegisterFlag
(
flag
);
// default registry
}
}
template
<
typename
FlagType
>
FlagRegisterer
::
FlagRegisterer
(
const
char
*
name
,
const
char
*
help
,
const
char
*
filename
,
FlagType
*
current_storage
,
FlagType
*
defvalue_storage
)
{
FlagValue
*
const
current
=
new
FlagValue
(
current_storage
,
false
);
FlagValue
*
const
defvalue
=
new
FlagValue
(
defvalue_storage
,
false
);
RegisterCommandLineFlag
(
name
,
help
,
filename
,
current
,
defvalue
);
}
// Force compiler to generate code for the given template specialization.
...
...
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