Skip to content

Commit 9998422

Browse files
committed
Perf: add is_trivially_copyable trait
Signed-off-by: Evgeny Malygin <emalygin@bloomberg.net>
1 parent adad71b commit 9998422

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

src/groups/bmq/bmqp/bmqp_protocol.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@
155155

156156
#include <bsl_limits.h>
157157
#include <bsl_string.h> // for bslstl::StringRef
158+
#include <bsl_type_traits.h>
158159
#include <bsla_annotations.h>
160+
#include <bslmf_nestedtraitdeclaration.h>
159161
#include <bsls_assert.h>
160162
#include <bsls_types.h>
161163

@@ -170,6 +172,9 @@ namespace bmqp {
170172
/// for unlimited retransmission and the second bit being a flag for a
171173
/// potentially poisonous message.
172174
struct RdaInfo {
175+
// TRAITS
176+
BSLMF_NESTED_TRAIT_DECLARATION(RdaInfo, bsl::is_trivially_copyable)
177+
173178
// FRIENDS
174179
friend bool operator==(const RdaInfo& lhs, const RdaInfo& rhs);
175180

@@ -260,6 +265,9 @@ bool operator==(const RdaInfo& lhs, const RdaInfo& rhs);
260265

261266
/// VST representing a sub-queue which will be receiving a message.
262267
struct SubQueueInfo {
268+
// TRAITS
269+
BSLMF_NESTED_TRAIT_DECLARATION(SubQueueInfo, bsl::is_trivially_copyable)
270+
263271
// FRIENDS
264272
friend bool operator==(const SubQueueInfo& lhs, const SubQueueInfo& rhs);
265273

@@ -773,6 +781,9 @@ struct EventHeader {
773781
// after the EventHeader). For now, this is left up for future
774782
// enhancement as there are no use-case for an event level option.
775783

784+
// TRAITS
785+
BSLMF_NESTED_TRAIT_DECLARATION(EventHeader, bsl::is_trivially_copyable)
786+
776787
private:
777788
// PRIVATE CONSTANTS
778789
static const int k_FRAGMENT_NUM_BITS = 1;
@@ -990,6 +1001,9 @@ struct OptionHeader {
9901001
// };
9911002
//..
9921003

1004+
// TRAITS
1005+
BSLMF_NESTED_TRAIT_DECLARATION(OptionHeader, bsl::is_trivially_copyable)
1006+
9931007
private:
9941008
// PRIVATE CONSTANTS
9951009
static const int k_TYPE_NUM_BITS = 6;
@@ -1153,6 +1167,10 @@ struct MessagePropertiesHeader {
11531167
// field. The payload following message properties area does not have any
11541168
// alignment requirement though.
11551169

1170+
// TRAITS
1171+
BSLMF_NESTED_TRAIT_DECLARATION(MessagePropertiesHeader,
1172+
bsl::is_trivially_copyable)
1173+
11561174
private:
11571175
// PRIVATE CONSTANTS
11581176
static const int k_MSG_PROPS_AREA_WORDS_LOWER_NUM_BITS = 16;
@@ -1268,6 +1286,10 @@ struct MessagePropertyHeader {
12681286
// This struct must be 2-byte aligned. See comments in
12691287
// 'MessagePropertiesHeader' for details.
12701288

1289+
// TRAITS
1290+
BSLMF_NESTED_TRAIT_DECLARATION(MessagePropertyHeader,
1291+
bsl::is_trivially_copyable)
1292+
12711293
private:
12721294
// PRIVATE CONSTANTS
12731295
static const int k_RESERVED1_NUM_BITS = 1;
@@ -1327,6 +1349,9 @@ struct MessagePropertyHeader {
13271349
};
13281350

13291351
struct SchemaWireId {
1352+
// TRAITS
1353+
BSLMF_NESTED_TRAIT_DECLARATION(SchemaWireId, bsl::is_trivially_copyable)
1354+
13301355
public:
13311356
static const unsigned k_MAX_VALUE = 0xffff;
13321357

@@ -1425,6 +1450,9 @@ struct PutHeader {
14251450
// ptr += 4 * (headerWords + optionsWords)
14261451
//..
14271452

1453+
// TRAITS
1454+
BSLMF_NESTED_TRAIT_DECLARATION(PutHeader, bsl::is_trivially_copyable)
1455+
14281456
private:
14291457
// FRIENDS
14301458
friend struct PutHeaderFlags;
@@ -1761,6 +1789,9 @@ struct AckHeader {
17611789
// Reserved..............: For alignment and extension ~ must be 0
17621790
//..
17631791

1792+
// TRAITS
1793+
BSLMF_NESTED_TRAIT_DECLARATION(AckHeader, bsl::is_trivially_copyable)
1794+
17641795
private:
17651796
// PRIVATE CONSTANTS
17661797
static const int k_HEADER_WORDS_NUM_BITS = 4;
@@ -1893,6 +1924,9 @@ struct AckMessage {
18931924
// producer of the Put event this Ack is a response of)
18941925
//..
18951926

1927+
// TRAITS
1928+
BSLMF_NESTED_TRAIT_DECLARATION(AckMessage, bsl::is_trivially_copyable)
1929+
18961930
private:
18971931
// PRIVATE CONSTANTS
18981932
static const int k_STATUS_NUM_BITS = 4;
@@ -2028,6 +2062,9 @@ struct PushHeader {
20282062
// The (optional) data payload then follows this header. If present, data
20292063
// must be padded.
20302064

2065+
// TRAITS
2066+
BSLMF_NESTED_TRAIT_DECLARATION(PushHeader, bsl::is_trivially_copyable)
2067+
20312068
private:
20322069
// FRIENDS
20332070
friend struct PushHeaderFlags;
@@ -2329,6 +2366,9 @@ struct ConfirmHeader {
23292366
// Reserved (R)..........: For alignment and extension ~ must be 0
23302367
//..
23312368

2369+
// TRAITS
2370+
BSLMF_NESTED_TRAIT_DECLARATION(ConfirmHeader, bsl::is_trivially_copyable)
2371+
23322372
private:
23332373
// PRIVATE CONSTANTS
23342374
static const int k_HEADER_WORDS_NUM_BITS = 4;
@@ -2429,6 +2469,9 @@ struct ConfirmMessage {
24292469
//..
24302470
//
24312471

2472+
// TRAITS
2473+
BSLMF_NESTED_TRAIT_DECLARATION(ConfirmMessage, bsl::is_trivially_copyable)
2474+
24322475
private:
24332476
// DATA
24342477
bdlb::BigEndianInt32 d_queueId;
@@ -2499,6 +2542,9 @@ struct RejectHeader {
24992542
// Reserved (R)..........: For alignment and extension ~ must be 0
25002543
//..
25012544

2545+
// TRAITS
2546+
BSLMF_NESTED_TRAIT_DECLARATION(RejectHeader, bsl::is_trivially_copyable)
2547+
25022548
private:
25032549
// PRIVATE CONSTANTS
25042550
static const int k_HEADER_WORDS_NUM_BITS = 4;
@@ -2599,6 +2645,9 @@ struct RejectMessage {
25992645
//..
26002646
//
26012647

2648+
// TRAITS
2649+
BSLMF_NESTED_TRAIT_DECLARATION(RejectMessage, bsl::is_trivially_copyable)
2650+
26022651
private:
26032652
// DATA
26042653
bdlb::BigEndianInt32 d_queueId;
@@ -2648,6 +2697,10 @@ struct RejectMessage {
26482697

26492698
/// This struct represents a Replication Receipt
26502699
struct ReplicationReceipt {
2700+
// TRAITS
2701+
BSLMF_NESTED_TRAIT_DECLARATION(ReplicationReceipt,
2702+
bsl::is_trivially_copyable)
2703+
26512704
bdlb::BigEndianUint32 d_partitionId;
26522705

26532706
bdlb::BigEndianUint32 d_seqNumUpperBits;
@@ -2798,6 +2851,9 @@ struct StorageHeader {
27982851
// that data payload is optional. There is no data payload for
27992852
// 'mqbs::StorageMessageType::e_SYNCPOINT'.
28002853

2854+
// TRAITS
2855+
BSLMF_NESTED_TRAIT_DECLARATION(StorageHeader, bsl::is_trivially_copyable)
2856+
28012857
private:
28022858
// FRIENDS
28032859
friend struct StorageHeaderFlags;
@@ -3182,6 +3238,9 @@ struct RecoveryHeader {
31823238
//
31833239
// The data payload then follows this header. Data must be padded.
31843240

3241+
// TRAITS
3242+
BSLMF_NESTED_TRAIT_DECLARATION(RecoveryHeader, bsl::is_trivially_copyable)
3243+
31853244
public:
31863245
// PUBLIC CLASS DATA
31873246

@@ -3353,6 +3412,10 @@ struct RecoveryHeader {
33533412
/// even > 0 | new style, w/ schema | ASSERT_SAFE
33543413
/// odd > 1 | new style, w/ schema, recycled | ASSERT_SAFE
33553414
struct MessagePropertiesInfo {
3415+
// TRAITS
3416+
BSLMF_NESTED_TRAIT_DECLARATION(MessagePropertiesInfo,
3417+
bsl::is_trivially_copyable)
3418+
33563419
public:
33573420
// PUBLIC TYPES
33583421
typedef unsigned short SchemaIdType;

src/groups/mqb/mqbi/mqbi_storage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@
5454
#include <bsl_memory.h>
5555
#include <bsl_ostream.h>
5656
#include <bsl_string.h>
57+
#include <bsl_type_traits.h>
5758
#include <bsl_utility.h>
5859
#include <bsl_vector.h>
5960
#include <bslma_managedptr.h>
61+
#include <bslmf_nestedtraitdeclaration.h>
6062
#include <bsls_types.h>
6163

6264
namespace BloombergLP {
@@ -274,6 +276,9 @@ bool operator!=(const StorageMessageAttributes& lhs,
274276
struct AppMessage {
275277
// VST to track the state associated with (GUID, App) pair.
276278

279+
// TRAITS
280+
BSLMF_NESTED_TRAIT_DECLARATION(AppMessage, bsl::is_trivially_copyable)
281+
277282
// PULIC TYOES
278283
enum State { e_NONE = 0, e_PUT = 1, e_PUSH = 2, e_CONFIRM = 3 };
279284

0 commit comments

Comments
 (0)