Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
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
spdlog
Commits
21065ec0
Commit
21065ec0
authored
Oct 18, 2014
by
gabi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proper swap and move operations on swap oss
parent
e6345e00
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
21 deletions
+41
-21
bench.cpp
example/bench.cpp
+1
-1
fast_oss.h
include/c11log/details/fast_oss.h
+24
-5
log_msg.h
include/c11log/details/log_msg.h
+2
-2
stack_buf.h
include/c11log/details/stack_buf.h
+10
-11
logger.h
include/c11log/logger.h
+4
-2
No files found.
example/bench.cpp
View file @
21065ec0
...
...
@@ -15,7 +15,7 @@ using namespace c11log;
using
namespace
utils
;
int
main
(
int
argc
,
char
*
argv
[])
int
main
_
(
int
argc
,
char
*
argv
[])
{
const
unsigned
int
howmany
=
argc
<=
1
?
500000
:
atoi
(
argv
[
1
]);
...
...
include/c11log/details/fast_oss.h
View file @
21065ec0
...
...
@@ -22,7 +22,6 @@ public:
stack_devicebuf
()
=
default
;
~
stack_devicebuf
()
=
default
;
stack_devicebuf
&
operator
=
(
const
stack_devicebuf
&
)
=
delete
;
stack_devicebuf
(
const
stack_devicebuf
&
other
)
:
std
::
basic_streambuf
<
char
>
(),
_stackbuf
(
other
.
_stackbuf
)
{}
...
...
@@ -34,6 +33,12 @@ public:
other
.
clear
();
}
stack_devicebuf
&
operator
=
(
stack_devicebuf
&&
other
)
{
std
::
swap
(
_stackbuf
,
other
.
_stackbuf
);
return
*
this
;
}
const
stackbuf_t
&
buf
()
const
{
return
_stackbuf
;
...
...
@@ -76,8 +81,7 @@ public:
fast_oss
()
:
std
::
ostream
(
&
_dev
)
{}
~
fast_oss
()
=
default
;
fast_oss
&
operator
=
(
const
fast_oss
&
other
)
=
delete
;
fast_oss
&
operator
=
(
const
fast_oss
&&
other
)
=
delete
;
fast_oss
(
const
fast_oss
&
other
)
:
std
::
basic_ios
<
char
>
(),
std
::
ostream
(
&
_dev
),
_dev
(
other
.
_dev
)
{}
...
...
@@ -87,6 +91,21 @@ public:
other
.
clear
();
}
fast_oss
&
operator
=
(
fast_oss
&&
other
)
{
swap
(
*
this
,
other
);
return
*
this
;
}
void
swap
(
fast_oss
&
first
,
fast_oss
&
second
)
// nothrow
{
using
std
::
swap
;
swap
(
first
.
_dev
,
second
.
_dev
);
}
std
::
string
str
()
{
auto
buffer
=
_dev
.
buf
();
...
...
@@ -136,8 +155,8 @@ public:
auto
buffer
=
oss
.
buf
();
_dev
.
sputn
(
buffer
.
data
(),
buffer
.
size
());
}
private
:
stack_devicebuf
_dev
;
};
...
...
include/c11log/details/log_msg.h
View file @
21065ec0
...
...
@@ -38,8 +38,8 @@ struct log_msg
swap
(
l
.
level
,
r
.
level
);
swap
(
l
.
time
,
r
.
time
);
swap
(
l
.
tm_time
,
r
.
tm_time
);
//
swap(l.raw, r.raw);
//
swap(l.formatted, r.formatted);
swap
(
l
.
raw
,
r
.
raw
);
swap
(
l
.
formatted
,
r
.
formatted
);
}
...
...
include/c11log/details/stack_buf.h
View file @
21065ec0
...
...
@@ -19,9 +19,6 @@ public:
static
const
unsigned
short
stack_size
=
STACK_SIZE
;
stack_buf
()
:
_v
(),
_stack_size
(
0
)
{}
~
stack_buf
()
=
default
;
stack_buf
&
operator
=
(
const
stack_buf
&
other
)
=
delete
;
stack_buf
(
const
stack_buf
&
other
)
:
stack_buf
(
other
,
delegate_copy_move
{})
{}
...
...
@@ -29,6 +26,16 @@ public:
{
other
.
clear
();
}
template
<
class
T1
>
stack_buf
&
operator
=
(
T1
&&
other
)
{
_stack_size
=
other
.
_stack_size
;
if
(
other
.
vector_used
())
_v
=
std
::
forward
<
T1
>
(
other
).
_v
;
else
std
::
copy_n
(
other
.
_stack_array
.
begin
(),
other
.
_stack_size
,
_stack_array
.
begin
());
return
*
this
;
}
void
append
(
const
char
*
buf
,
std
::
size_t
buf_size
)
{
...
...
@@ -62,14 +69,6 @@ public:
_v
.
clear
();
}
/* bufpair_t get() const
{
if (vector_used())
return bufpair_t(_v.data(), _v.size());
else
return bufpair_t(_stack_array.data(), _stack_size);
}*/
const
char
*
data
()
const
{
if
(
vector_used
())
...
...
include/c11log/logger.h
View file @
21065ec0
...
...
@@ -114,8 +114,10 @@ inline c11log::logger::logger(const std::string& logger_name, const It& begin, c
template
<
typename
...
Args
>
inline
c11log
::
details
::
line_logger
c11log
::
logger
::
log
(
level
::
level_enum
lvl
,
const
Args
&
...
args
)
{
details
::
line_logger
l
(
this
,
lvl
,
should_log
(
lvl
));
_variadic_log
(
l
,
args
...);
bool
msg_enabled
=
should_log
(
lvl
);
details
::
line_logger
l
(
this
,
lvl
,
msg_enabled
);
if
(
msg_enabled
)
_variadic_log
(
l
,
args
...);
return
l
;
}
...
...
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