Skip to content

Commit e86d938

Browse files
committed
Use constexpr instead of const
1 parent 7068e8e commit e86d938

File tree

2 files changed

+60
-60
lines changed

2 files changed

+60
-60
lines changed

src/remote/remote.h

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,24 @@ DEFINE_TRACE_ROUTINE(remote_trace);
8888

8989
#endif
9090

91-
const int BLOB_LENGTH = 16384;
91+
constexpr int BLOB_LENGTH = 16384;
9292

9393
#include "../remote/protocol.h"
9494
#include "fb_blk.h"
9595

9696
// Prefetch constants
9797

98-
const ULONG MAX_PACKETS_PER_BATCH = 16;
98+
constexpr ULONG MAX_PACKETS_PER_BATCH = 16;
9999

100-
const ULONG MIN_ROWS_PER_BATCH = 10;
101-
const ULONG MAX_ROWS_PER_BATCH = 1000;
100+
constexpr ULONG MIN_ROWS_PER_BATCH = 10;
101+
constexpr ULONG MAX_ROWS_PER_BATCH = 1000;
102102

103-
const ULONG MAX_BATCH_CACHE_SIZE = 1024 * 1024; // 1 MB
103+
constexpr ULONG MAX_BATCH_CACHE_SIZE = 1024 * 1024; // 1 MB
104104

105-
const ULONG DEFAULT_BLOBS_CACHE_SIZE = 10 * 1024 * 1024; // 10 MB
105+
constexpr ULONG DEFAULT_BLOBS_CACHE_SIZE = 10 * 1024 * 1024; // 10 MB
106106

107-
const ULONG MAX_INLINE_BLOB_SIZE = MAX_USHORT;
108-
const ULONG DEFAULT_INLINE_BLOB_SIZE = MAX_USHORT;
107+
constexpr ULONG MAX_INLINE_BLOB_SIZE = MAX_USHORT;
108+
constexpr ULONG DEFAULT_INLINE_BLOB_SIZE = MAX_USHORT;
109109

110110
// fwd. decl.
111111
namespace Firebird {
@@ -591,7 +591,7 @@ struct Rsr : public Firebird::GlobalStorage, public TypedHandle<rem_type_rsr>
591591
: curBpb(*getDefaultMemoryPool()), hdrPrevious(0), segmented(false)
592592
{ }
593593

594-
static const ULONG SIZEOF_BLOB_HEAD = sizeof(ISC_QUAD) + 2 * sizeof(ULONG);
594+
static constexpr ULONG SIZEOF_BLOB_HEAD = sizeof(ISC_QUAD) + 2 * sizeof(ULONG);
595595

596596
typedef Firebird::HalfStaticArray<UCHAR, 64> Bpb;
597597
Bpb curBpb;
@@ -626,8 +626,8 @@ struct Rsr : public Firebird::GlobalStorage, public TypedHandle<rem_type_rsr>
626626
PAST_BOF = 256 // BOF was returned by fetch from this statement
627627
};
628628

629-
static const auto STREAM_END = (BOF_SET | EOF_SET);
630-
static const auto PAST_END = (PAST_BOF | PAST_EOF);
629+
static constexpr auto STREAM_END = (BOF_SET | EOF_SET);
630+
static constexpr auto PAST_END = (PAST_BOF | PAST_EOF);
631631

632632
public:
633633
Rsr() :
@@ -789,8 +789,8 @@ typedef Firebird::Array<rem_que_packet> PacketQueue;
789789
class ServerAuthBase
790790
{
791791
public:
792-
static const unsigned AUTH_CONTINUE = 0x01;
793-
static const unsigned AUTH_COND_ACCEPT = 0x02;
792+
static constexpr unsigned AUTH_CONTINUE = 0x01;
793+
static constexpr unsigned AUTH_COND_ACCEPT = 0x02;
794794

795795
virtual ~ServerAuthBase();
796796
virtual bool authenticate(PACKET* send, unsigned flags = 0) = 0;
@@ -899,10 +899,10 @@ class KnownServerKey : public Firebird::AutoStorage
899899
};
900900

901901
// Tags for clumplets, passed from server to client
902-
const UCHAR TAG_KEY_TYPE = 0;
903-
const UCHAR TAG_KEY_PLUGINS = 1;
904-
const UCHAR TAG_KNOWN_PLUGINS = 2;
905-
const UCHAR TAG_PLUGIN_SPECIFIC = 3;
902+
constexpr UCHAR TAG_KEY_TYPE = 0;
903+
constexpr UCHAR TAG_KEY_PLUGINS = 1;
904+
constexpr UCHAR TAG_KNOWN_PLUGINS = 2;
905+
constexpr UCHAR TAG_PLUGIN_SPECIFIC = 3;
906906

907907

908908
typedef Firebird::GetPlugins<Firebird::IClient> AuthClientPlugins;
@@ -1090,8 +1090,8 @@ class SrvAuthBlock final :
10901090
Auth::WriterImplementation authBlockWriter;
10911091

10921092
// extractNewKeys flags
1093-
static const ULONG EXTRACT_PLUGINS_LIST = 0x1;
1094-
static const ULONG ONLY_CLEANUP = 0x2;
1093+
static constexpr ULONG EXTRACT_PLUGINS_LIST = 0x1;
1094+
static constexpr ULONG ONLY_CLEANUP = 0x2;
10951095

10961096
explicit SrvAuthBlock(rem_port* p_port)
10971097
: port(p_port),
@@ -1136,26 +1136,26 @@ class SrvAuthBlock final :
11361136
};
11371137

11381138

1139-
const signed char WIRECRYPT_BROKEN = -1;
1140-
const signed char WIRECRYPT_DISABLED = 0;
1141-
const signed char WIRECRYPT_ENABLED = 1;
1142-
const signed char WIRECRYPT_REQUIRED = 2;
1139+
constexpr signed char WIRECRYPT_BROKEN = -1;
1140+
constexpr signed char WIRECRYPT_DISABLED = 0;
1141+
constexpr signed char WIRECRYPT_ENABLED = 1;
1142+
constexpr signed char WIRECRYPT_REQUIRED = 2;
11431143

11441144
// port_flags
1145-
const USHORT PORT_symmetric = 0x0001; // Server/client architectures are symmetic
1146-
const USHORT PORT_async = 0x0002; // Port is asynchronous channel for events
1147-
const USHORT PORT_no_oob = 0x0004; // Don't send out of band data
1148-
const USHORT PORT_disconnect = 0x0008; // Disconnect is in progress
1149-
const USHORT PORT_dummy_pckt_set= 0x0010; // A dummy packet interval is set
1150-
//const USHORT PORT_partial_data = 0x0020; // Physical packet doesn't contain all API packet
1151-
const USHORT PORT_lazy = 0x0040; // Deferred operations are allowed
1152-
const USHORT PORT_server = 0x0080; // Server (not client) port
1153-
const USHORT PORT_detached = 0x0100; // op_detach, op_drop_database or op_service_detach was processed
1154-
const USHORT PORT_rdb_shutdown = 0x0200; // Database is shut down
1155-
const USHORT PORT_connecting = 0x0400; // Aux connection waits for a channel to be activated by client
1156-
//const USHORT PORT_z_data = 0x0800; // Zlib incoming buffer has data left after decompression
1157-
const USHORT PORT_compressed = 0x1000; // Compress outgoing stream (does not affect incoming)
1158-
const USHORT PORT_released = 0x2000; // release(), complementary to the first addRef() in constructor, was called
1145+
constexpr USHORT PORT_symmetric = 0x0001; // Server/client architectures are symmetic
1146+
constexpr USHORT PORT_async = 0x0002; // Port is asynchronous channel for events
1147+
constexpr USHORT PORT_no_oob = 0x0004; // Don't send out of band data
1148+
constexpr USHORT PORT_disconnect = 0x0008; // Disconnect is in progress
1149+
constexpr USHORT PORT_dummy_pckt_set= 0x0010; // A dummy packet interval is set
1150+
//constexpr USHORT PORT_partial_data = 0x0020; // Physical packet doesn't contain all API packet
1151+
constexpr USHORT PORT_lazy = 0x0040; // Deferred operations are allowed
1152+
constexpr USHORT PORT_server = 0x0080; // Server (not client) port
1153+
constexpr USHORT PORT_detached = 0x0100; // op_detach, op_drop_database or op_service_detach was processed
1154+
constexpr USHORT PORT_rdb_shutdown = 0x0200; // Database is shut down
1155+
constexpr USHORT PORT_connecting = 0x0400; // Aux connection waits for a channel to be activated by client
1156+
//constexpr USHORT PORT_z_data = 0x0800; // Zlib incoming buffer has data left after decompression
1157+
constexpr USHORT PORT_compressed = 0x1000; // Compress outgoing stream (does not affect incoming)
1158+
constexpr USHORT PORT_released = 0x2000; // release(), complementary to the first addRef() in constructor, was called
11591159

11601160
// forward decl
11611161
class RemotePortGuard;

src/remote/remote_def.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,47 +44,47 @@
4444

4545
#if defined(__sun)
4646
# ifdef sparc
47-
const P_ARCH ARCHITECTURE = arch_sun4;
47+
constexpr P_ARCH ARCHITECTURE = arch_sun4;
4848
#elif (defined i386 || defined AMD64)
49-
const P_ARCH ARCHITECTURE = arch_sunx86;
49+
constexpr P_ARCH ARCHITECTURE = arch_sunx86;
5050
# else
51-
const P_ARCH ARCHITECTURE = arch_sun;
51+
constexpr P_ARCH ARCHITECTURE = arch_sun;
5252
# endif
5353
#elif defined(HPUX)
54-
const P_ARCH ARCHITECTURE = arch_hpux;
54+
constexpr P_ARCH ARCHITECTURE = arch_hpux;
5555
#elif (defined AIX || defined AIX_PPC)
56-
const P_ARCH ARCHITECTURE = arch_rt;
56+
constexpr P_ARCH ARCHITECTURE = arch_rt;
5757
#elif defined(LINUX)
58-
const P_ARCH ARCHITECTURE = arch_linux;
58+
constexpr P_ARCH ARCHITECTURE = arch_linux;
5959
#elif defined(FREEBSD)
60-
const P_ARCH ARCHITECTURE = arch_freebsd;
60+
constexpr P_ARCH ARCHITECTURE = arch_freebsd;
6161
#elif defined(NETBSD)
62-
const P_ARCH ARCHITECTURE = arch_netbsd;
62+
constexpr P_ARCH ARCHITECTURE = arch_netbsd;
6363
#elif defined(DARWIN) && defined(__ppc__)
64-
const P_ARCH ARCHITECTURE = arch_darwin_ppc;
64+
constexpr P_ARCH ARCHITECTURE = arch_darwin_ppc;
6565
#elif defined(WIN_NT) && defined(AMD64)
66-
const P_ARCH ARCHITECTURE = arch_winnt_64;
66+
constexpr P_ARCH ARCHITECTURE = arch_winnt_64;
6767
#elif defined(I386)
68-
const P_ARCH ARCHITECTURE = arch_intel_32;
68+
constexpr P_ARCH ARCHITECTURE = arch_intel_32;
6969
#elif defined(DARWIN64)
70-
const P_ARCH ARCHITECTURE = arch_darwin_x64;
70+
constexpr P_ARCH ARCHITECTURE = arch_darwin_x64;
7171
#elif defined(DARWINPPC64)
72-
const P_ARCH ARCHITECTURE = arch_darwin_ppc64;
72+
constexpr P_ARCH ARCHITECTURE = arch_darwin_ppc64;
7373
#elif defined(ARM)
74-
const P_ARCH ARCHITECTURE = arch_arm;
74+
constexpr P_ARCH ARCHITECTURE = arch_arm;
7575
#endif
7676

7777

7878
// port_server_flags
7979

80-
const USHORT SRVR_server = 1; // server
81-
const USHORT SRVR_multi_client = 2; // multi-client server
82-
const USHORT SRVR_debug = 4; // debug run
83-
const USHORT SRVR_inet = 8; // Inet protocol
84-
const USHORT SRVR_xnet = 16; // Xnet protocol (Win32)
85-
const USHORT SRVR_non_service = 32; // not running as an NT service
86-
const USHORT SRVR_high_priority = 64; // fork off server at high priority
87-
const USHORT SRVR_thread_per_port = 128; // bind thread to a port
88-
const USHORT SRVR_no_icon = 256; // tell the server not to show the icon
80+
constexpr USHORT SRVR_server = 1; // server
81+
constexpr USHORT SRVR_multi_client = 2; // multi-client server
82+
constexpr USHORT SRVR_debug = 4; // debug run
83+
constexpr USHORT SRVR_inet = 8; // Inet protocol
84+
constexpr USHORT SRVR_xnet = 16; // Xnet protocol (Win32)
85+
constexpr USHORT SRVR_non_service = 32; // not running as an NT service
86+
constexpr USHORT SRVR_high_priority = 64; // fork off server at high priority
87+
constexpr USHORT SRVR_thread_per_port = 128; // bind thread to a port
88+
constexpr USHORT SRVR_no_icon = 256; // tell the server not to show the icon
8989

9090
#endif /* REMOTE_REMOTE_DEF_H */

0 commit comments

Comments
 (0)