Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
d52cf87d
Commit
d52cf87d
authored
Sep 17, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid un necessary move when popping circular_q
parent
2ddd6895
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
13 deletions
+21
-13
include/spdlog/details/backtracer-inl.h
include/spdlog/details/backtracer-inl.h
+3
-3
include/spdlog/details/circular_q.h
include/spdlog/details/circular_q.h
+14
-7
include/spdlog/details/mpmc_blocking_q.h
include/spdlog/details/mpmc_blocking_q.h
+2
-1
include/spdlog/sinks/daily_file_sink.h
include/spdlog/sinks/daily_file_sink.h
+2
-2
No files found.
include/spdlog/details/backtracer-inl.h
View file @
d52cf87d
...
@@ -65,9 +65,9 @@ SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log
...
@@ -65,9 +65,9 @@ SPDLOG_INLINE void backtracer::foreach_pop(std::function<void(const details::log
std
::
lock_guard
<
std
::
mutex
>
lock
{
mutex_
};
std
::
lock_guard
<
std
::
mutex
>
lock
{
mutex_
};
while
(
!
messages_
.
empty
())
while
(
!
messages_
.
empty
())
{
{
log_msg_buffer
popped
;
auto
&
front_msg
=
messages_
.
front
()
;
messages_
.
pop_front
(
popped
);
messages_
.
pop_front
();
fun
(
popped
);
fun
(
front_msg
);
}
}
}
}
}
// namespace details
}
// namespace details
...
...
include/spdlog/details/circular_q.h
View file @
d52cf87d
...
@@ -60,15 +60,18 @@ public:
...
@@ -60,15 +60,18 @@ public:
}
}
}
}
// Return reference to the front item.
// If there are no elements in the container, the behavior is undefined.
T
&
front
()
{
return
v_
[
head_
];
}
// Pop item from front.
// Pop item from front.
// If there are no elements in the container, the behavior is undefined.
// If there are no elements in the container, the behavior is undefined.
void
pop_front
(
T
&
popped_item
)
void
pop_front
()
{
{
if
(
max_items_
>
0
)
head_
=
(
head_
+
1
)
%
max_items_
;
{
popped_item
=
std
::
move
(
v_
[
head_
]);
head_
=
(
head_
+
1
)
%
max_items_
;
}
}
}
bool
empty
()
const
bool
empty
()
const
...
@@ -79,7 +82,11 @@ public:
...
@@ -79,7 +82,11 @@ public:
bool
full
()
const
bool
full
()
const
{
{
// head is ahead of the tail by 1
// head is ahead of the tail by 1
return
((
tail_
+
1
)
%
max_items_
)
==
head_
;
if
(
max_items_
>
0
)
{
return
((
tail_
+
1
)
%
max_items_
)
==
head_
;
}
return
true
;
}
}
size_t
overrun_counter
()
const
size_t
overrun_counter
()
const
...
...
include/spdlog/details/mpmc_blocking_q.h
View file @
d52cf87d
...
@@ -59,7 +59,8 @@ public:
...
@@ -59,7 +59,8 @@ public:
{
{
return
false
;
return
false
;
}
}
q_
.
pop_front
(
popped_item
);
popped_item
=
std
::
move
(
q_
.
front
());
q_
.
pop_front
();
}
}
pop_cv_
.
notify_one
();
pop_cv_
.
notify_one
();
return
true
;
return
true
;
...
...
include/spdlog/sinks/daily_file_sink.h
View file @
d52cf87d
...
@@ -139,8 +139,8 @@ private:
...
@@ -139,8 +139,8 @@ private:
filename_t
current_file
=
filename
();
filename_t
current_file
=
filename
();
if
(
filenames_q_
.
full
())
if
(
filenames_q_
.
full
())
{
{
filename_t
old_filename
;
auto
&
old_filename
=
filenames_q_
.
front
()
;
filenames_q_
.
pop_front
(
old_filename
);
filenames_q_
.
pop_front
();
bool
ok
=
remove_if_exists
(
old_filename
)
==
0
;
bool
ok
=
remove_if_exists
(
old_filename
)
==
0
;
if
(
!
ok
)
if
(
!
ok
)
{
{
...
...
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