Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
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
json
Commits
184dab60
Commit
184dab60
authored
Oct 05, 2017
by
Perry Kundert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accelerate access to underlying std::istream streambuf
parent
f775922c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/json.hpp
src/json.hpp
+4
-2
No files found.
src/json.hpp
View file @
184dab60
...
...
@@ -1417,6 +1417,7 @@ class input_stream_adapter : public input_adapter_protocol
}
explicit
input_stream_adapter
(
std
::
istream
&
i
)
:
is
(
i
)
,
sb
(
i
.
rdbuf
())
{
// Ignore Byte Order Mark at start of input
int
c
;
...
...
@@ -1448,18 +1449,19 @@ class input_stream_adapter : public input_adapter_protocol
int
get_character
()
override
{
int
c
=
is
.
rdbuf
()
->
sbumpc
();
// Avoided for performance: int c = is.get();
int
c
=
sb
->
sbumpc
();
// Avoided for performance: int c = is.get();
return
c
<
0
?
c
:
(
c
&
0xFF
);
// faster than == std::char_traits<char>::eof()
}
void
unget_character
()
override
{
is
.
rdbuf
()
->
sungetc
();
// Avoided for performance: is.unget();
sb
->
sungetc
();
// Avoided for performance: is.unget();
}
private:
/// the associated input stream
std
::
istream
&
is
;
std
::
streambuf
*
sb
;
};
/// input adapter for buffer input
...
...
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