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
ba4ed0eb
Commit
ba4ed0eb
authored
Nov 11, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
micro optimize scoped_padder
parent
3cdf2b7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
include/spdlog/details/pattern_formatter.h
include/spdlog/details/pattern_formatter.h
+11
-11
No files found.
include/spdlog/details/pattern_formatter.h
View file @
ba4ed0eb
...
...
@@ -55,22 +55,22 @@ public:
if
(
padinfo_
.
width_
<=
wrapped_size
)
{
nchars
_
=
0
;
total_pad
_
=
0
;
return
;
}
nchars
_
=
padinfo
.
width_
-
wrapped_size
;
total_pad
_
=
padinfo
.
width_
-
wrapped_size
;
if
(
padinfo_
.
side_
==
padding_info
::
left
)
{
pad_it
(
nchars
_
);
nchars
_
=
0
;
pad_it
(
total_pad
_
);
total_pad
_
=
0
;
}
else
if
(
padinfo_
.
side_
==
padding_info
::
center
)
{
auto
half_
chars
=
nchars
_
/
2
;
auto
reminder
=
nchars_
%
2
;
pad_it
(
half_
chars
);
nchars_
=
half_chars
+
reminder
;
//
for the right side
auto
half_
pad
=
total_pad
_
/
2
;
auto
reminder
=
total_pad_
&
1
;
pad_it
(
half_
pad
);
total_pad_
=
half_pad
+
reminder
;
//
for the right side
}
}
...
...
@@ -81,9 +81,9 @@ public:
~
scoped_pad
()
{
if
(
nchars
_
)
if
(
total_pad
_
)
{
pad_it
(
nchars
_
);
pad_it
(
total_pad
_
);
}
}
...
...
@@ -98,7 +98,7 @@ private:
const
padding_info
&
padinfo_
;
fmt
::
memory_buffer
&
dest_
;
size_t
nchars
_
;
size_t
total_pad
_
;
string_view_t
spaces_
=
" "
" "
;
};
...
...
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