Skip to content

Commit d78d32a

Browse files
committed
constexpr in sdw
1 parent 5f654e7 commit d78d32a

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/jrd/sdw.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,14 @@ void SDW_dump_pages(thread_db* tdbb)
325325

326326
CCH_FETCH(tdbb, &window, LCK_read, pag_undefined);
327327

328-
class Pio : public CryptoManager::IOCallback
328+
class Pio final : public CryptoManager::IOCallback
329329
{
330330
public:
331-
Pio(Shadow* s, BufferDesc* b)
331+
Pio(Shadow* s, BufferDesc* b) noexcept
332332
: shadow(s), bdb(b)
333333
{ }
334334

335-
bool callback(thread_db* tdbb, FbStatusVector* status, Ods::pag* page)
335+
bool callback(thread_db* tdbb, FbStatusVector* status, Ods::pag* page) override
336336
{
337337
return CCH_write_all_shadows(tdbb, shadow, bdb, page, status, false);
338338
}
@@ -441,7 +441,7 @@ void SDW_init(thread_db* tdbb, bool activate, bool delete_files)
441441
// set up the lock block for synchronizing addition of new shadows
442442

443443
header_page* header; // for sizeof here, used later
444-
const USHORT key_length = sizeof(header->hdr_shadow_count);
444+
constexpr USHORT key_length = sizeof(header->hdr_shadow_count);
445445
Lock* lock = FB_NEW_RPT(*dbb->dbb_permanent, key_length)
446446
Lock(tdbb, key_length, LCK_shadow, dbb, blocking_ast_shadowing);
447447
dbb->dbb_shadow_lock = lock;
@@ -573,7 +573,7 @@ void SDW_notify(thread_db* tdbb)
573573
}
574574

575575

576-
bool SDW_rollover_to_shadow(thread_db* tdbb, jrd_file* file, const bool inAst)
576+
bool SDW_rollover_to_shadow(thread_db* tdbb, const jrd_file* file, const bool inAst)
577577
{
578578
/**************************************
579579
*
@@ -926,7 +926,7 @@ static void activate_shadow(thread_db* tdbb)
926926
*
927927
**************************************/
928928
SET_TDBB(tdbb);
929-
Database* dbb = tdbb->getDatabase();
929+
const Database* dbb = tdbb->getDatabase();
930930
CHECK_DBB(dbb);
931931

932932
gds__log("activating shadow file %s", dbb->dbb_filename.c_str());
@@ -1043,7 +1043,7 @@ static bool check_for_file(thread_db* tdbb, const SCHAR* name, USHORT length)
10431043
**************************************/
10441044

10451045
SET_TDBB(tdbb);
1046-
Database* dbb = tdbb->getDatabase();
1046+
const Database* dbb = tdbb->getDatabase();
10471047
const Firebird::PathName path(name, length);
10481048

10491049
try {

src/jrd/sdw.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ class Shadow : public pool_alloc<type_sdw>
4242

4343
// sdw_flags
4444

45-
const USHORT SDW_dumped = 1; // bit set when file has been copied
46-
const USHORT SDW_shutdown = 2; // stop shadowing on next cache flush
47-
const USHORT SDW_manual = 4; // shadow is a manual shadow--don't delete
48-
const USHORT SDW_delete = 8; // delete the shadow at the next shutdown
49-
const USHORT SDW_found = 16; // flag to mark shadow found in database
50-
const USHORT SDW_rollover = 32; // this shadow was rolled over to when the main db file went away
51-
const USHORT SDW_conditional = 64; // shadow to be used if another shadow becomes unavailable
52-
53-
/* these macros are a convenient combination of switches:
45+
inline constexpr USHORT SDW_dumped = 1; // bit set when file has been copied
46+
inline constexpr USHORT SDW_shutdown = 2; // stop shadowing on next cache flush
47+
inline constexpr USHORT SDW_manual = 4; // shadow is a manual shadow--don't delete
48+
inline constexpr USHORT SDW_delete = 8; // delete the shadow at the next shutdown
49+
inline constexpr USHORT SDW_found = 16; // flag to mark shadow found in database
50+
inline constexpr USHORT SDW_rollover = 32; // this shadow was rolled over to when the main db file went away
51+
inline constexpr USHORT SDW_conditional = 64; // shadow to be used if another shadow becomes unavailable
52+
53+
/* these constants are a convenient combination of switches:
5454
the first specifies the shadow is invalid for writing to;
5555
the second specifies that the shadow no SLONGer exists and the
5656
shadow block simply hasn't been cleared out yet */
5757

58-
const USHORT SDW_INVALID = (SDW_shutdown | SDW_delete | SDW_rollover | SDW_conditional);
59-
const USHORT SDW_IGNORE = (SDW_shutdown | SDW_delete);
58+
inline constexpr USHORT SDW_INVALID = (SDW_shutdown | SDW_delete | SDW_rollover | SDW_conditional);
59+
inline constexpr USHORT SDW_IGNORE = (SDW_shutdown | SDW_delete);
6060

6161
} //namespace Jrd
6262

src/jrd/sdw_proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void SDW_get_shadows(Jrd::thread_db* tdbb);
3737
void SDW_init(Jrd::thread_db* tdbb, bool, bool);
3838
bool SDW_lck_update(Jrd::thread_db*, SLONG);
3939
void SDW_notify(Jrd::thread_db* tdbb);
40-
bool SDW_rollover_to_shadow(Jrd::thread_db* tdbb, Jrd::jrd_file*, const bool);
40+
bool SDW_rollover_to_shadow(Jrd::thread_db* tdbb, const Jrd::jrd_file*, const bool);
4141
// It's never called directly, but through SDW_check().
4242
//void SDW_shutdown_shadow(Jrd::Shadow*);
4343
void SDW_start(Jrd::thread_db* tdbb, const TEXT*, USHORT, USHORT, bool);

0 commit comments

Comments
 (0)