Skip to content

Commit 3024301

Browse files
committed
constexpr + noexcept File/TempFile/TempSpace
1 parent 338be5c commit 3024301

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

src/common/classes/File.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ class File
3939
virtual FB_SIZE_T read(offset_t, void*, FB_SIZE_T) = 0;
4040
virtual FB_SIZE_T write(offset_t, const void*, FB_SIZE_T) = 0;
4141

42-
virtual void unlink() = 0;
42+
virtual void unlink() noexcept = 0;
4343

44-
virtual offset_t getSize() const = 0;
44+
virtual offset_t getSize() const noexcept = 0;
4545
};
4646

4747
class ZeroBuffer
4848
{
49-
static const FB_SIZE_T DEFAULT_SIZE = 1024 * 256;
50-
static const FB_SIZE_T SYS_PAGE_SIZE = 1024 * 4;
49+
static constexpr FB_SIZE_T DEFAULT_SIZE = 1024 * 256;
50+
static constexpr FB_SIZE_T SYS_PAGE_SIZE = 1024 * 4;
5151

5252
public:
5353
explicit ZeroBuffer(MemoryPool& p, FB_SIZE_T size = DEFAULT_SIZE)
@@ -59,8 +59,8 @@ class ZeroBuffer
5959
memset(bufAligned, 0, size);
6060
}
6161

62-
const char* getBuffer() const { return bufAligned; }
63-
FB_SIZE_T getSize() const { return bufSize; }
62+
const char* getBuffer() const noexcept { return bufAligned; }
63+
FB_SIZE_T getSize() const noexcept { return bufSize; }
6464

6565
private:
6666
Firebird::Array<char> buffer;

src/common/classes/TempFile.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ namespace Firebird {
5656

5757
// Const definitions
5858

59-
static const char* ENV_VAR = "FIREBIRD_TMP";
60-
static const char* DEFAULT_PATH =
59+
static constexpr const char* ENV_VAR = "FIREBIRD_TMP";
60+
static constexpr const char* DEFAULT_PATH =
6161
#if defined(UNIX)
6262
"/tmp/";
6363
#elif defined(ANDROID)
@@ -68,11 +68,11 @@ static const char* DEFAULT_PATH =
6868
NULL;
6969
#endif
7070

71-
static const char* const NAME_PATTERN = "XXXXXX";
71+
static constexpr const char* NAME_PATTERN = "XXXXXX";
7272

7373
#ifdef WIN_NT
74-
static const char* const NAME_LETTERS = "abcdefghijklmnopqrstuvwxyz0123456789";
75-
static const FB_SIZE_T MAX_TRIES = 256;
74+
static constexpr const char* NAME_LETTERS = "abcdefghijklmnopqrstuvwxyz0123456789";
75+
static constexpr FB_SIZE_T MAX_TRIES = 256;
7676
#endif
7777

7878
// we need a class here only to return memory on shutdown and avoid
@@ -388,7 +388,7 @@ FB_SIZE_T TempFile::write(offset_t offset, const void* buffer, FB_SIZE_T length)
388388
// Unlinks the file
389389
//
390390

391-
void TempFile::unlink()
391+
void TempFile::unlink() noexcept
392392
{
393393
#if defined(WIN_NT)
394394
doUnlink = true;

src/common/classes/TempFile.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ class TempFile : public File
4848

4949
virtual ~TempFile();
5050

51-
FB_SIZE_T read(offset_t, void*, FB_SIZE_T);
52-
FB_SIZE_T write(offset_t, const void*, FB_SIZE_T);
51+
FB_SIZE_T read(offset_t, void*, FB_SIZE_T) override;
52+
FB_SIZE_T write(offset_t, const void*, FB_SIZE_T) override;
5353

54-
void unlink();
54+
void unlink() noexcept override;
5555

56-
offset_t getSize() const
56+
offset_t getSize() const noexcept override
5757
{
5858
return size;
5959
}
6060

6161
void extend(offset_t);
6262

63-
const PathName& getName() const
63+
const PathName& getName() const noexcept
6464
{
6565
return filename;
6666
}

src/jrd/TempSpace.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ FB_SIZE_T TempSpace::minBlockSize = 0;
4444

4545
namespace
4646
{
47-
const size_t MIN_TEMP_BLOCK_SIZE = 64 * 1024;
47+
constexpr size_t MIN_TEMP_BLOCK_SIZE = 64 * 1024;
4848

4949
class TempCacheLimitGuard
5050
{
5151
public:
52-
explicit TempCacheLimitGuard(Database* dbb) :
52+
explicit TempCacheLimitGuard(Database* dbb) noexcept :
5353
m_dbb(dbb),
5454
m_size(0)
5555
{}
@@ -70,7 +70,7 @@ namespace
7070
return false;
7171
}
7272

73-
void commit()
73+
void commit() noexcept
7474
{
7575
m_size = 0;
7676
}

src/jrd/TempSpace.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ class TempSpace : public Firebird::File
3737
TempSpace(MemoryPool& pool, const Firebird::PathName& prefix, bool dynamic = true);
3838
virtual ~TempSpace();
3939

40-
FB_SIZE_T read(offset_t offset, void* buffer, FB_SIZE_T length);
41-
FB_SIZE_T write(offset_t offset, const void* buffer, FB_SIZE_T length);
40+
FB_SIZE_T read(offset_t offset, void* buffer, FB_SIZE_T length) override;
41+
FB_SIZE_T write(offset_t offset, const void* buffer, FB_SIZE_T length) override;
4242

43-
void unlink() {}
43+
void unlink() noexcept override {}
4444

45-
offset_t getSize() const
45+
offset_t getSize() const noexcept override
4646
{
4747
return logicalSize;
4848
}
@@ -72,7 +72,7 @@ class TempSpace : public Firebird::File
7272
class Block
7373
{
7474
public:
75-
Block(Block* tail, size_t length)
75+
Block(Block* tail, size_t length) noexcept
7676
: next(NULL), size(length)
7777
{
7878
if (tail)
@@ -87,8 +87,8 @@ class TempSpace : public Firebird::File
8787
virtual FB_SIZE_T read(offset_t offset, void* buffer, FB_SIZE_T length) = 0;
8888
virtual FB_SIZE_T write(offset_t offset, const void* buffer, FB_SIZE_T length) = 0;
8989

90-
virtual UCHAR* inMemory(offset_t offset, size_t size) const = 0;
91-
virtual bool sameFile(const Firebird::TempFile* file) const = 0;
90+
virtual UCHAR* inMemory(offset_t offset, size_t size) const noexcept = 0;
91+
virtual bool sameFile(const Firebird::TempFile* file) const noexcept = 0;
9292

9393
Block *prev;
9494
Block *next;
@@ -98,7 +98,7 @@ class TempSpace : public Firebird::File
9898
class MemoryBlock : public Block
9999
{
100100
public:
101-
MemoryBlock(UCHAR* memory, Block* tail, size_t length)
101+
MemoryBlock(UCHAR* memory, Block* tail, size_t length) noexcept
102102
: Block(tail, length), ptr(memory)
103103
{}
104104

@@ -107,18 +107,18 @@ class TempSpace : public Firebird::File
107107
delete[] ptr;
108108
}
109109

110-
FB_SIZE_T read(offset_t offset, void* buffer, FB_SIZE_T length);
111-
FB_SIZE_T write(offset_t offset, const void* buffer, FB_SIZE_T length);
110+
FB_SIZE_T read(offset_t offset, void* buffer, FB_SIZE_T length) override;
111+
FB_SIZE_T write(offset_t offset, const void* buffer, FB_SIZE_T length) override;
112112

113-
UCHAR* inMemory(offset_t offset, size_t _size) const
113+
UCHAR* inMemory(offset_t offset, size_t _size) const noexcept override
114114
{
115115
if ((offset < this->size) && (offset + _size <= this->size))
116116
return ptr + offset;
117117

118118
return NULL;
119119
}
120120

121-
bool sameFile(const Firebird::TempFile*) const
121+
bool sameFile(const Firebird::TempFile*) const noexcept override
122122
{
123123
return false;
124124
}
@@ -130,7 +130,7 @@ class TempSpace : public Firebird::File
130130
class InitialBlock : public MemoryBlock
131131
{
132132
public:
133-
InitialBlock(UCHAR* memory, size_t length)
133+
InitialBlock(UCHAR* memory, size_t length) noexcept
134134
: MemoryBlock(memory, NULL, length)
135135
{}
136136

@@ -155,15 +155,15 @@ class TempSpace : public Firebird::File
155155

156156
~FileBlock() {}
157157

158-
FB_SIZE_T read(offset_t offset, void* buffer, FB_SIZE_T length);
159-
FB_SIZE_T write(offset_t offset, const void* buffer, FB_SIZE_T length);
158+
FB_SIZE_T read(offset_t offset, void* buffer, FB_SIZE_T length) override;
159+
FB_SIZE_T write(offset_t offset, const void* buffer, FB_SIZE_T length) override;
160160

161-
UCHAR* inMemory(offset_t /*offset*/, size_t /*a_size*/) const
161+
UCHAR* inMemory(offset_t /*offset*/, size_t /*a_size*/) const noexcept override
162162
{
163163
return NULL;
164164
}
165165

166-
bool sameFile(const Firebird::TempFile* aFile) const
166+
bool sameFile(const Firebird::TempFile* aFile) const noexcept override
167167
{
168168
return (aFile == this->file);
169169
}
@@ -182,7 +182,7 @@ class TempSpace : public Firebird::File
182182
class Segment
183183
{
184184
public:
185-
Segment(offset_t aPosition, offset_t aSize) :
185+
Segment(offset_t aPosition, offset_t aSize) noexcept :
186186
position(aPosition), size(aSize), prev(nullptr), next(nullptr)
187187
{}
188188

@@ -191,7 +191,7 @@ class TempSpace : public Firebird::File
191191
Segment* prev;
192192
Segment* next;
193193

194-
static const offset_t& generate(const void* /*sender*/, const Segment* segment)
194+
static const offset_t& generate(const void* /*sender*/, const Segment* segment) noexcept
195195
{
196196
return segment->position;
197197
}
@@ -200,17 +200,17 @@ class TempSpace : public Firebird::File
200200
class SegmentsStack
201201
{
202202
public:
203-
SegmentsStack() : size(0), tail(nullptr)
203+
SegmentsStack() noexcept : size(0), tail(nullptr)
204204
{}
205205

206-
SegmentsStack(offset_t aSize, Segment* aSegment) :
206+
SegmentsStack(offset_t aSize, Segment* aSegment) noexcept :
207207
size(aSize), tail(aSegment)
208208
{}
209209

210210
offset_t size;
211211
Segment* tail;
212212

213-
static const offset_t& generate(const void* /*sender*/, const SegmentsStack& segment)
213+
static const offset_t& generate(const void* /*sender*/, const SegmentsStack& segment) noexcept
214214
{
215215
return segment.size;
216216
}

0 commit comments

Comments
 (0)