Skip to content

Commit 69f8975

Browse files
committed
constexpr + noexcept TraceLog
1 parent 56c474a commit 69f8975

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/jrd/trace/TraceLog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ using namespace Firebird;
5252

5353
namespace Jrd {
5454

55-
const unsigned int INIT_LOG_SIZE = 1024*1024; // 1MB
56-
const unsigned int FREE_SPACE_THRESHOLD = INIT_LOG_SIZE / 4;
55+
constexpr unsigned int INIT_LOG_SIZE = 1024*1024; // 1MB
56+
constexpr unsigned int FREE_SPACE_THRESHOLD = INIT_LOG_SIZE / 4;
5757

5858
TraceLog::TraceLog(MemoryPool& pool, const PathName& fileName, bool reader) :
5959
m_reader(reader),
@@ -268,7 +268,7 @@ void TraceLog::extend(FB_SIZE_T size)
268268

269269
FB_SIZE_T TraceLog::getUsed()
270270
{
271-
TraceLogHeader* header = m_sharedMemory->getHeader();
271+
const TraceLogHeader* header = m_sharedMemory->getHeader();
272272

273273
if (header->readPos < header->writePos)
274274
return (header->writePos - header->readPos);
@@ -280,14 +280,14 @@ FB_SIZE_T TraceLog::getUsed()
280280

281281
FB_SIZE_T TraceLog::getFree(bool useMax)
282282
{
283-
TraceLogHeader* header = m_sharedMemory->getHeader();
283+
const TraceLogHeader* header = m_sharedMemory->getHeader();
284284
return (useMax ? header->maxSize : header->allocated) - sizeof(TraceLogHeader) - getUsed() - 1;
285285
}
286286

287287
bool TraceLog::isFull()
288288
{
289289
TraceLogGuard guard(this);
290-
TraceLogHeader* header = m_sharedMemory->getHeader();
290+
const TraceLogHeader* header = m_sharedMemory->getHeader();
291291
return header->flags & FLAG_FULL;
292292
}
293293

src/jrd/trace/TraceLog.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333

3434
namespace Jrd {
3535

36-
struct TraceLogHeader : public Firebird::MemoryHeader
36+
struct TraceLogHeader final : public Firebird::MemoryHeader
3737
{
38-
static const USHORT TRACE_LOG_VERSION = 2;
38+
static constexpr USHORT TRACE_LOG_VERSION = 2;
3939

4040
ULONG readPos;
4141
ULONG writePos;
@@ -44,7 +44,7 @@ struct TraceLogHeader : public Firebird::MemoryHeader
4444
ULONG flags;
4545
};
4646

47-
class TraceLog : public Firebird::IpcObject
47+
class TraceLog final : public Firebird::IpcObject
4848
{
4949
public:
5050
TraceLog(Firebird::MemoryPool& pool, const Firebird::PathName& fileName, bool reader);
@@ -58,8 +58,8 @@ class TraceLog : public Firebird::IpcObject
5858

5959
private:
6060
// flags in header
61-
const ULONG FLAG_FULL = 0x0001; // log is full, set by writer, reset by reader
62-
const ULONG FLAG_DONE = 0x0002; // set when reader is gone
61+
static constexpr ULONG FLAG_FULL = 0x0001; // log is full, set by writer, reset by reader
62+
static constexpr ULONG FLAG_DONE = 0x0002; // set when reader is gone
6363

6464
void mutexBug(int osErrorCode, const char* text) override;
6565
bool initialize(Firebird::SharedMemoryBase*, bool) override;

0 commit comments

Comments
 (0)