Skip to content

Commit 7a3bcbe

Browse files
committed
constexpr + noexcept Routine
1 parent 36d7381 commit 7a3bcbe

File tree

4 files changed

+50
-44
lines changed

4 files changed

+50
-44
lines changed

src/jrd/Function.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ namespace Jrd
5858
static int blockingAst(void*);
5959

6060
public:
61-
int getObjectType() const override
61+
int getObjectType() const noexcept override
6262
{
6363
return obj_udf;
6464
}
6565

66-
SLONG getSclType() const override
66+
SLONG getSclType() const noexcept override
6767
{
6868
return obj_functions;
6969
}

src/jrd/Routine.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ MsgMetadata* Routine::createMetadata(const Array<NestConst<Parameter> >& paramet
4444
i != parameters.end();
4545
++i)
4646
{
47-
dsc d((*i)->prm_desc);
47+
const dsc d((*i)->prm_desc);
4848
metadata->addItem((*i)->prm_name, (*i)->prm_nullable, d);
4949
}
5050

@@ -59,7 +59,7 @@ Format* Routine::createFormat(MemoryPool& pool, IMessageMetadata* params, bool a
5959
{
6060
FbLocalStatus status;
6161

62-
unsigned count = params->getCount(&status);
62+
const unsigned count = params->getCount(&status);
6363
status.check();
6464

6565
Format* format = Format::newFormat(pool, count * 2 + (addEof ? 1 : 0));
@@ -71,9 +71,9 @@ Format* Routine::createFormat(MemoryPool& pool, IMessageMetadata* params, bool a
7171
{
7272
unsigned descOffset, nullOffset, descDtype, descLength;
7373

74-
unsigned type = params->getType(&status, i);
74+
const unsigned type = params->getType(&status, i);
7575
status.check();
76-
unsigned len = params->getLength(&status, i);
76+
const unsigned len = params->getLength(&status, i);
7777
status.check();
7878
runOffset = fb_utils::sqlTypeToDsc(runOffset, type, len, &descDtype, &descLength,
7979
&descOffset, &nullOffset);
@@ -149,7 +149,7 @@ void Routine::checkReload(thread_db* tdbb)
149149
}
150150

151151
// Parse routine BLR and debug info.
152-
void Routine::parseBlr(thread_db* tdbb, CompilerScratch* csb, bid* blob_id, bid* blobDbg)
152+
void Routine::parseBlr(thread_db* tdbb, CompilerScratch* csb, const bid* blob_id, bid* blobDbg)
153153
{
154154
Jrd::Attachment* attachment = tdbb->getAttachment();
155155

@@ -199,7 +199,7 @@ void Routine::parseMessages(thread_db* tdbb, CompilerScratch* csb, BlrReader blr
199199
while (csb->csb_blr_reader.getByte() == blr_message)
200200
{
201201
const USHORT msgNumber = csb->csb_blr_reader.getByte();
202-
USHORT count = csb->csb_blr_reader.getWord();
202+
const USHORT count = csb->csb_blr_reader.getWord();
203203
Format* format = Format::newFormat(*tdbb->getDefaultPool(), count);
204204

205205
USHORT padField;

src/jrd/Routine.h

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -71,77 +71,83 @@ namespace Jrd
7171
}
7272

7373
public:
74-
static const USHORT FLAG_SCANNED = 1; // Field expressions scanned
75-
static const USHORT FLAG_OBSOLETE = 2; // Procedure known gonzo
76-
static const USHORT FLAG_BEING_SCANNED = 4; // New procedure needs dependencies during scan
77-
static const USHORT FLAG_BEING_ALTERED = 8; // Procedure is getting altered
74+
static constexpr USHORT FLAG_SCANNED = 1; // Field expressions scanned
75+
static constexpr USHORT FLAG_OBSOLETE = 2; // Procedure known gonzo
76+
static constexpr USHORT FLAG_BEING_SCANNED = 4; // New procedure needs dependencies during scan
77+
static constexpr USHORT FLAG_BEING_ALTERED = 8; // Procedure is getting altered
7878
// This flag is used to make sure that MET_remove_routine
7979
// does not delete and remove procedure block from cache
8080
// so dfw.epp:modify_procedure() can flip procedure body without
8181
// invalidating procedure pointers from other parts of metadata cache
82-
static const USHORT FLAG_CHECK_EXISTENCE = 16; // Existence lock released
83-
static const USHORT FLAG_RELOAD = 32; // Recompile before execution
84-
static const USHORT FLAG_CLEARED = 64; // Routine cleared but not removed from cache
82+
static constexpr USHORT FLAG_CHECK_EXISTENCE = 16; // Existence lock released
83+
static constexpr USHORT FLAG_RELOAD = 32; // Recompile before execution
84+
static constexpr USHORT FLAG_CLEARED = 64; // Routine cleared but not removed from cache
8585

86-
static const USHORT MAX_ALTER_COUNT = 64; // Number of times an in-cache routine can be altered
86+
static constexpr USHORT MAX_ALTER_COUNT = 64; // Number of times an in-cache routine can be altered
8787

8888
static Firebird::MsgMetadata* createMetadata(
8989
const Firebird::Array<NestConst<Parameter> >& parameters, bool isExtern);
9090
static Format* createFormat(MemoryPool& pool, Firebird::IMessageMetadata* params, bool addEof);
9191

9292
public:
93-
USHORT getId() const
93+
USHORT getId() const noexcept
9494
{
9595
fb_assert(!subRoutine);
9696
return id;
9797
}
9898

99-
void setId(USHORT value) { id = value; }
99+
void setId(USHORT value) noexcept { id = value; }
100100

101-
const QualifiedName& getName() const { return name; }
101+
const QualifiedName& getName() const noexcept { return name; }
102102
void setName(const QualifiedName& value) { name = value; }
103103

104-
const QualifiedName& getSecurityName() const { return securityName; }
104+
const QualifiedName& getSecurityName() const noexcept { return securityName; }
105105
void setSecurityName(const QualifiedName& value) { securityName = value; }
106106

107-
/*const*/ Statement* getStatement() const { return statement; }
107+
/*const*/ Statement* getStatement() const noexcept { return statement; }
108108
void setStatement(Statement* value);
109109

110-
bool isSubRoutine() const { return subRoutine; }
111-
void setSubRoutine(bool value) { subRoutine = value; }
110+
bool isSubRoutine() const noexcept { return subRoutine; }
111+
void setSubRoutine(bool value) noexcept { subRoutine = value; }
112112

113-
bool isImplemented() const { return implemented; }
114-
void setImplemented(bool value) { implemented = value; }
113+
bool isImplemented() const noexcept { return implemented; }
114+
void setImplemented(bool value) noexcept { implemented = value; }
115115

116-
bool isDefined() const { return defined; }
117-
void setDefined(bool value) { defined = value; }
116+
bool isDefined() const noexcept { return defined; }
117+
void setDefined(bool value) noexcept { defined = value; }
118118

119119
void checkReload(thread_db* tdbb);
120120

121-
USHORT getDefaultCount() const { return defaultCount; }
122-
void setDefaultCount(USHORT value) { defaultCount = value; }
121+
USHORT getDefaultCount() const noexcept { return defaultCount; }
122+
void setDefaultCount(USHORT value) noexcept { defaultCount = value; }
123123

124-
const Format* getInputFormat() const { return inputFormat; }
125-
void setInputFormat(const Format* value) { inputFormat = value; }
124+
const Format* getInputFormat() const noexcept { return inputFormat; }
125+
void setInputFormat(const Format* value) noexcept { inputFormat = value; }
126126

127-
const Format* getOutputFormat() const { return outputFormat; }
128-
void setOutputFormat(const Format* value) { outputFormat = value; }
127+
const Format* getOutputFormat() const noexcept { return outputFormat; }
128+
void setOutputFormat(const Format* value) noexcept { outputFormat = value; }
129129

130-
const Firebird::Array<NestConst<Parameter> >& getInputFields() const { return inputFields; }
131-
Firebird::Array<NestConst<Parameter> >& getInputFields() { return inputFields; }
130+
const Firebird::Array<NestConst<Parameter> >& getInputFields() const noexcept
131+
{
132+
return inputFields;
133+
}
134+
Firebird::Array<NestConst<Parameter> >& getInputFields() noexcept { return inputFields; }
132135

133-
const Firebird::Array<NestConst<Parameter> >& getOutputFields() const { return outputFields; }
134-
Firebird::Array<NestConst<Parameter> >& getOutputFields() { return outputFields; }
136+
const Firebird::Array<NestConst<Parameter> >& getOutputFields() const noexcept
137+
{
138+
return outputFields;
139+
}
140+
Firebird::Array<NestConst<Parameter> >& getOutputFields() noexcept { return outputFields; }
135141

136-
void parseBlr(thread_db* tdbb, CompilerScratch* csb, bid* blob_id, bid* blobDbg);
142+
void parseBlr(thread_db* tdbb, CompilerScratch* csb, const bid* blob_id, bid* blobDbg);
137143
void parseMessages(thread_db* tdbb, CompilerScratch* csb, Firebird::BlrReader blrReader);
138144

139-
bool isUsed() const
145+
bool isUsed() const noexcept
140146
{
141147
return useCount != 0;
142148
}
143149

144-
void addRef()
150+
void addRef() noexcept
145151
{
146152
++useCount;
147153
}
@@ -156,8 +162,8 @@ namespace Jrd
156162
virtual void releaseExternal() {};
157163

158164
public:
159-
virtual int getObjectType() const = 0;
160-
virtual SLONG getSclType() const = 0;
165+
virtual int getObjectType() const noexcept = 0;
166+
virtual SLONG getSclType() const noexcept = 0;
161167
virtual bool checkCache(thread_db* tdbb) const = 0;
162168
virtual void clearCache(thread_db* tdbb) = 0;
163169

src/jrd/jrd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ class jrd_prc final : public Routine
234234
}
235235

236236
public:
237-
int getObjectType() const override
237+
int getObjectType() const noexcept override
238238
{
239239
return obj_procedure;
240240
}
241241

242-
SLONG getSclType() const override
242+
SLONG getSclType() const noexcept override
243243
{
244244
return obj_procedures;
245245
}

0 commit comments

Comments
 (0)