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
da82d8e2
Commit
da82d8e2
authored
Mar 17, 2014
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial reserver of std_devicebuf=128
parent
d8ddfe5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
15 deletions
+14
-15
example.cpp
example/example.cpp
+0
-2
fast_oss.h
include/c11log/details/fast_oss.h
+14
-13
No files found.
example/example.cpp
View file @
da82d8e2
...
...
@@ -20,8 +20,6 @@ int main(int argc, char* argv[])
{
if
(
argc
||
argv
)
{};
std
::
string
s
;
cout
<<
"STRING cap: "
<<
format
(
s
.
capacity
())
<<
endl
;
auto
fsink
=
std
::
make_shared
<
sinks
::
rotating_file_sink
>
(
"log"
,
"txt"
,
1024
*
1024
*
50
,
5
,
0
);
//auto fsink = std::make_shared<sinks::simple_file_sink>("simplelog", "txt");
...
...
include/c11log/details/fast_oss.h
View file @
da82d8e2
...
...
@@ -12,7 +12,7 @@ namespace details
class
str_devicebuf
:
public
std
::
streambuf
{
public
:
public
:
str_devicebuf
()
=
default
;
~
str_devicebuf
()
=
default
;
...
...
@@ -33,31 +33,32 @@ public:
}
protected
:
virtual
int
sync
()
override
int
sync
()
override
{
return
0
;
}
virtual
std
::
streamsize
xsputn
(
const
char_type
*
s
,
std
::
streamsize
count
)
override
{
auto
ssize
=
_str
.
size
();
auto
cap_left
=
_str
.
capacity
()
-
ssize
;
if
(
cap_left
<
static_cast
<
std
::
size_t
>
(
count
))
_str
.
reserve
(
ssize
+
count
+
128
);
_str
.
append
(
s
,
static_cast
<
unsigned
int
>
(
count
));
// copy the give buffer into the accumulated string.
// reserve initially 128 bytes which should be enough for common log lines
std
::
streamsize
xsputn
(
const
char_type
*
s
,
std
::
streamsize
count
)
override
{
if
(
_str
.
capacity
()
<
k_initial_reserve
)
{
_str
.
reserve
(
k_initial_reserve
);
}
_str
.
append
(
s
,
static_cast
<
unsigned
int
>
(
count
));
return
count
;
}
virtual
int_type
overflow
(
int_type
ch
)
override
int_type
overflow
(
int_type
ch
)
override
{
if
(
ch
!=
traits_type
::
eof
())
_str
.
append
((
char
*
)
&
ch
,
1
);
xsputn
((
char
*
)
&
ch
,
1
);
return
1
;
}
private
:
std
::
string
_str
;
static
constexpr
std
::
streamsize
k_initial_reserve
=
128
;
};
class
fast_oss
:
public
std
::
ostream
...
...
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