Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
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
rapidjson
Commits
f7a64c5e
Commit
f7a64c5e
authored
Apr 18, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RAPIDJSON_LIKELY/UNLIKELY and apply them in stack
parent
adb7d17e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
1 deletion
+36
-1
stack.h
include/rapidjson/internal/stack.h
+1
-1
rapidjson.h
include/rapidjson/rapidjson.h
+29
-0
rapidjsontest.cpp
test/perftest/rapidjsontest.cpp
+6
-0
No files found.
include/rapidjson/internal/stack.h
View file @
f7a64c5e
...
...
@@ -98,7 +98,7 @@ public:
template
<
typename
T
>
RAPIDJSON_FORCEINLINE
T
*
Push
(
size_t
count
=
1
)
{
// Expand the stack if needed
if
(
stackTop_
+
sizeof
(
T
)
*
count
>=
stackEnd_
)
if
(
RAPIDJSON_UNLIKELY
(
stackTop_
+
sizeof
(
T
)
*
count
>=
stackEnd_
)
)
Expand
<
T
>
(
count
);
T
*
ret
=
reinterpret_cast
<
T
*>
(
stackTop_
);
...
...
include/rapidjson/rapidjson.h
View file @
f7a64c5e
...
...
@@ -343,6 +343,35 @@ RAPIDJSON_NAMESPACE_END
RAPIDJSON_JOIN
(
StaticAssertTypedef
,
__LINE__
)
RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE
#endif
///////////////////////////////////////////////////////////////////////////////
// RAPIDJSON_LIKELY, RAPIDJSON_UNLIKELY
//! Compiler branching hint for expression with high probability to be true.
/*!
\ingroup RAPIDJSON_CONFIG
\param x Boolean expression likely to be true.
*/
#ifndef RAPIDJSON_LIKELY
#if defined(__GNUC__) || defined(__clang__)
#define RAPIDJSON_LIKELY(x) __builtin_expect(!!(x), 1)
#else
#define RAPIDJSON_LIKELY(x) x
#endif
#endif
//! Compiler branching hint for expression with low probability to be true.
/*!
\ingroup RAPIDJSON_CONFIG
\param x Boolean expression unlikely to be true.
*/
#ifndef RAPIDJSON_UNLIKELY
#if defined(__GNUC__) || defined(__clang__)
#define RAPIDJSON_UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define RAPIDJSON_UNLIKELY(x) x
#endif
#endif
///////////////////////////////////////////////////////////////////////////////
// Helpers
...
...
test/perftest/rapidjsontest.cpp
View file @
f7a64c5e
...
...
@@ -346,4 +346,10 @@ TEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_FileReadStream)) {
}
}
TEST_F
(
RapidJson
,
StringBuffer
)
{
StringBuffer
sb
;
for
(
int
i
=
0
;
i
<
32
*
1024
*
1024
;
i
++
)
sb
.
Put
(
i
&
0x7f
);
}
#endif // TEST_RAPIDJSON
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