Skip to content

Commit b44123c

Browse files
committed
Phase 122: Remove redundant inline specifiers from class member functions
Removed redundant 'inline' keywords from member functions defined inside class bodies. In C++, such functions are implicitly inline, making the explicit keyword unnecessary and verbose. Changes: - ltable.h: Node class (20 methods), Table class (8 methods) - lproto.h: ProtoDebugInfo (29 methods), Proto (58 methods) - lparser.h: Labellist (11 methods), Dyndata (11 methods), ActvarAccessor (4 methods), CodeBuffer (13 methods), ConstantPool (5 methods), VariableScope (7 methods), RegisterAllocator (4 methods), UpvalueTracker (4 methods) - lstack.h: LuaStack class (19 methods) - llex.h: InputScanner (11 methods), TokenState (4 methods), StringInterner (10 methods) Total: ~218 redundant inline specifiers removed across 5 header files. This change improves code clarity without affecting performance. Member functions defined within class bodies are implicitly inline per C++ standard. Note: Free functions and member functions defined outside class bodies still require explicit 'inline' to avoid ODR violations. Performance: 4.33s avg (5 runs: 4.70s, 4.25s, 4.15s, 4.34s, 4.20s) Target: ≤4.33s ✅ Tests: All passing ✅
1 parent 8697ff8 commit b44123c

File tree

5 files changed

+267
-267
lines changed

5 files changed

+267
-267
lines changed

src/compiler/llex.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,23 @@ class InputScanner {
9999

100100
public:
101101
// Accessors
102-
inline int getCurrent() const noexcept { return current; }
103-
inline int getLineNumber() const noexcept { return linenumber; }
104-
inline int getLastLine() const noexcept { return lastline; }
105-
inline ZIO* getZIO() const noexcept { return z; }
106-
inline TString* getSource() const noexcept { return source; }
102+
int getCurrent() const noexcept { return current; }
103+
int getLineNumber() const noexcept { return linenumber; }
104+
int getLastLine() const noexcept { return lastline; }
105+
ZIO* getZIO() const noexcept { return z; }
106+
TString* getSource() const noexcept { return source; }
107107

108-
inline void setCurrent(int c) noexcept { current = c; }
109-
inline void setLineNumber(int line) noexcept { linenumber = line; }
110-
inline void setLastLine(int line) noexcept { lastline = line; }
111-
inline void setZIO(ZIO* zio) noexcept { z = zio; }
112-
inline void setSource(TString* src) noexcept { source = src; }
108+
void setCurrent(int c) noexcept { current = c; }
109+
void setLineNumber(int line) noexcept { linenumber = line; }
110+
void setLastLine(int line) noexcept { lastline = line; }
111+
void setZIO(ZIO* zio) noexcept { z = zio; }
112+
void setSource(TString* src) noexcept { source = src; }
113113

114-
inline int& getLineNumberRef() noexcept { return linenumber; }
114+
int& getLineNumberRef() noexcept { return linenumber; }
115115

116116
// Operations
117-
inline void next() noexcept { current = zgetc(z); }
118-
inline bool currIsNewline() const noexcept { return current == '\n' || current == '\r'; }
117+
void next() noexcept { current = zgetc(z); }
118+
bool currIsNewline() const noexcept { return current == '\n' || current == '\r'; }
119119
};
120120

121121
/* Phase 94: Subsystem for token state management */
@@ -126,10 +126,10 @@ class TokenState {
126126

127127
public:
128128
// Accessors
129-
inline const Token& getCurrent() const noexcept { return current; }
130-
inline Token& getCurrentRef() noexcept { return current; }
131-
inline const Token& getLookahead() const noexcept { return lookahead; }
132-
inline Token& getLookaheadRef() noexcept { return lookahead; }
129+
const Token& getCurrent() const noexcept { return current; }
130+
Token& getCurrentRef() noexcept { return current; }
131+
const Token& getLookahead() const noexcept { return lookahead; }
132+
Token& getLookaheadRef() noexcept { return lookahead; }
133133
};
134134

135135
/* Phase 94: Subsystem for string interning and buffer management */
@@ -143,17 +143,17 @@ class StringInterner {
143143

144144
public:
145145
// Accessors
146-
inline Mbuffer* getBuffer() const noexcept { return buff; }
147-
inline Table* getTable() const noexcept { return h; }
148-
inline TString* getEnvName() const noexcept { return envn; }
149-
inline TString* getBreakName() const noexcept { return brkn; }
150-
inline TString* getGlobalName() const noexcept { return glbn; }
151-
152-
inline void setBuffer(Mbuffer* b) noexcept { buff = b; }
153-
inline void setTable(Table* table) noexcept { h = table; }
154-
inline void setEnvName(TString* env) noexcept { envn = env; }
155-
inline void setBreakName(TString* brk) noexcept { brkn = brk; }
156-
inline void setGlobalName(TString* gbl) noexcept { glbn = gbl; }
146+
Mbuffer* getBuffer() const noexcept { return buff; }
147+
Table* getTable() const noexcept { return h; }
148+
TString* getEnvName() const noexcept { return envn; }
149+
TString* getBreakName() const noexcept { return brkn; }
150+
TString* getGlobalName() const noexcept { return glbn; }
151+
152+
void setBuffer(Mbuffer* b) noexcept { buff = b; }
153+
void setTable(Table* table) noexcept { h = table; }
154+
void setEnvName(TString* env) noexcept { envn = env; }
155+
void setBreakName(TString* brk) noexcept { brkn = brk; }
156+
void setGlobalName(TString* gbl) noexcept { glbn = gbl; }
157157
};
158158

159159
/* Phase 95: Lexical state - focused on tokenization only

src/compiler/lparser.h

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -221,27 +221,27 @@ class Labellist {
221221
}
222222

223223
/* Accessor methods matching old interface */
224-
inline Labeldesc* getArr() noexcept { return vec.data(); }
225-
inline const Labeldesc* getArr() const noexcept { return vec.data(); }
226-
inline int getN() const noexcept { return static_cast<int>(vec.size()); }
227-
inline int getSize() const noexcept { return static_cast<int>(vec.capacity()); }
224+
Labeldesc* getArr() noexcept { return vec.data(); }
225+
const Labeldesc* getArr() const noexcept { return vec.data(); }
226+
int getN() const noexcept { return static_cast<int>(vec.size()); }
227+
int getSize() const noexcept { return static_cast<int>(vec.capacity()); }
228228

229229
/* Modifying size */
230-
inline void setN(int new_n) { vec.resize(static_cast<size_t>(new_n)); }
230+
void setN(int new_n) { vec.resize(static_cast<size_t>(new_n)); }
231231

232232
/* Direct vector access for modern operations */
233-
inline void push_back(const Labeldesc& desc) { vec.push_back(desc); }
234-
inline void reserve(int capacity) { vec.reserve(static_cast<size_t>(capacity)); }
235-
inline Labeldesc& operator[](int index) { return vec[static_cast<size_t>(index)]; }
236-
inline const Labeldesc& operator[](int index) const { return vec[static_cast<size_t>(index)]; }
233+
void push_back(const Labeldesc& desc) { vec.push_back(desc); }
234+
void reserve(int capacity) { vec.reserve(static_cast<size_t>(capacity)); }
235+
Labeldesc& operator[](int index) { return vec[static_cast<size_t>(index)]; }
236+
const Labeldesc& operator[](int index) const { return vec[static_cast<size_t>(index)]; }
237237

238238
/* For luaM_growvector replacement */
239-
inline void ensureCapacity(int needed) {
239+
void ensureCapacity(int needed) {
240240
if (needed > getSize()) {
241241
vec.reserve(static_cast<size_t>(needed));
242242
}
243243
}
244-
inline Labeldesc* allocateNew() {
244+
Labeldesc* allocateNew() {
245245
vec.resize(vec.size() + 1);
246246
return &vec.back();
247247
}
@@ -264,25 +264,25 @@ class Dyndata {
264264
}
265265

266266
/* Direct actvar accessor methods - avoid temporary object creation */
267-
inline Vardesc* actvarGetArr() noexcept { return actvar_vec.data(); }
268-
inline const Vardesc* actvarGetArr() const noexcept { return actvar_vec.data(); }
269-
inline int actvarGetN() const noexcept { return static_cast<int>(actvar_vec.size()); }
270-
inline int actvarGetSize() const noexcept { return static_cast<int>(actvar_vec.capacity()); }
267+
Vardesc* actvarGetArr() noexcept { return actvar_vec.data(); }
268+
const Vardesc* actvarGetArr() const noexcept { return actvar_vec.data(); }
269+
int actvarGetN() const noexcept { return static_cast<int>(actvar_vec.size()); }
270+
int actvarGetSize() const noexcept { return static_cast<int>(actvar_vec.capacity()); }
271271

272-
inline void actvarSetN(int new_n) { actvar_vec.resize(static_cast<size_t>(new_n)); }
273-
inline Vardesc& actvarAt(int index) { return actvar_vec[static_cast<size_t>(index)]; }
274-
inline const Vardesc& actvarAt(int index) const { return actvar_vec[static_cast<size_t>(index)]; }
272+
void actvarSetN(int new_n) { actvar_vec.resize(static_cast<size_t>(new_n)); }
273+
Vardesc& actvarAt(int index) { return actvar_vec[static_cast<size_t>(index)]; }
274+
const Vardesc& actvarAt(int index) const { return actvar_vec[static_cast<size_t>(index)]; }
275275

276-
inline Vardesc* actvarAllocateNew() {
276+
Vardesc* actvarAllocateNew() {
277277
actvar_vec.resize(actvar_vec.size() + 1);
278278
return &actvar_vec.back();
279279
}
280280

281281
/* Phase 116: std::span accessors for actvar array */
282-
inline std::span<Vardesc> actvarGetSpan() noexcept {
282+
std::span<Vardesc> actvarGetSpan() noexcept {
283283
return std::span(actvar_vec.data(), actvar_vec.size());
284284
}
285-
inline std::span<const Vardesc> actvarGetSpan() const noexcept {
285+
std::span<const Vardesc> actvarGetSpan() const noexcept {
286286
return std::span(actvar_vec.data(), actvar_vec.size());
287287
}
288288

@@ -292,13 +292,13 @@ class Dyndata {
292292
Dyndata* dyn;
293293
public:
294294
explicit ActvarAccessor(Dyndata* d) : dyn(d) {}
295-
inline int getN() const noexcept { return dyn->actvarGetN(); }
296-
inline void setN(int n) { dyn->actvarSetN(n); }
297-
inline Vardesc& operator[](int i) { return dyn->actvarAt(i); }
298-
inline Vardesc* allocateNew() { return dyn->actvarAllocateNew(); }
295+
int getN() const noexcept { return dyn->actvarGetN(); }
296+
void setN(int n) { dyn->actvarSetN(n); }
297+
Vardesc& operator[](int i) { return dyn->actvarAt(i); }
298+
Vardesc* allocateNew() { return dyn->actvarAllocateNew(); }
299299
};
300300

301-
inline ActvarAccessor actvar() noexcept { return ActvarAccessor{this}; }
301+
ActvarAccessor actvar() noexcept { return ActvarAccessor{this}; }
302302
};
303303

304304

@@ -324,35 +324,35 @@ class CodeBuffer {
324324

325325
public:
326326
/* Inline accessors for reading */
327-
inline int getPC() const noexcept { return pc; }
328-
inline int getLastTarget() const noexcept { return lasttarget; }
329-
inline int getPreviousLine() const noexcept { return previousline; }
330-
inline int getNAbsLineInfo() const noexcept { return nabslineinfo; }
331-
inline lu_byte getInstructionsWithAbs() const noexcept { return iwthabs; }
327+
int getPC() const noexcept { return pc; }
328+
int getLastTarget() const noexcept { return lasttarget; }
329+
int getPreviousLine() const noexcept { return previousline; }
330+
int getNAbsLineInfo() const noexcept { return nabslineinfo; }
331+
lu_byte getInstructionsWithAbs() const noexcept { return iwthabs; }
332332

333333
/* Setters */
334-
inline void setPC(int pc_) noexcept { pc = pc_; }
335-
inline void setLastTarget(int lasttarget_) noexcept { lasttarget = lasttarget_; }
336-
inline void setPreviousLine(int previousline_) noexcept { previousline = previousline_; }
337-
inline void setNAbsLineInfo(int nabslineinfo_) noexcept { nabslineinfo = nabslineinfo_; }
338-
inline void setInstructionsWithAbs(lu_byte iwthabs_) noexcept { iwthabs = iwthabs_; }
334+
void setPC(int pc_) noexcept { pc = pc_; }
335+
void setLastTarget(int lasttarget_) noexcept { lasttarget = lasttarget_; }
336+
void setPreviousLine(int previousline_) noexcept { previousline = previousline_; }
337+
void setNAbsLineInfo(int nabslineinfo_) noexcept { nabslineinfo = nabslineinfo_; }
338+
void setInstructionsWithAbs(lu_byte iwthabs_) noexcept { iwthabs = iwthabs_; }
339339

340340
/* Increment/decrement methods */
341-
inline void incrementPC() noexcept { pc++; }
342-
inline void decrementPC() noexcept { pc--; }
343-
inline int postIncrementPC() noexcept { return pc++; }
344-
inline void incrementNAbsLineInfo() noexcept { nabslineinfo++; }
345-
inline void decrementNAbsLineInfo() noexcept { nabslineinfo--; }
346-
inline int postIncrementNAbsLineInfo() noexcept { return nabslineinfo++; }
347-
inline lu_byte postIncrementInstructionsWithAbs() noexcept { return iwthabs++; }
348-
inline void decrementInstructionsWithAbs() noexcept { iwthabs--; }
341+
void incrementPC() noexcept { pc++; }
342+
void decrementPC() noexcept { pc--; }
343+
int postIncrementPC() noexcept { return pc++; }
344+
void incrementNAbsLineInfo() noexcept { nabslineinfo++; }
345+
void decrementNAbsLineInfo() noexcept { nabslineinfo--; }
346+
int postIncrementNAbsLineInfo() noexcept { return nabslineinfo++; }
347+
lu_byte postIncrementInstructionsWithAbs() noexcept { return iwthabs++; }
348+
void decrementInstructionsWithAbs() noexcept { iwthabs--; }
349349

350350
/* Reference accessors for compound assignments */
351-
inline int& getPCRef() noexcept { return pc; }
352-
inline int& getLastTargetRef() noexcept { return lasttarget; }
353-
inline int& getPreviousLineRef() noexcept { return previousline; }
354-
inline int& getNAbsLineInfoRef() noexcept { return nabslineinfo; }
355-
inline lu_byte& getInstructionsWithAbsRef() noexcept { return iwthabs; }
351+
int& getPCRef() noexcept { return pc; }
352+
int& getLastTargetRef() noexcept { return lasttarget; }
353+
int& getPreviousLineRef() noexcept { return previousline; }
354+
int& getNAbsLineInfoRef() noexcept { return nabslineinfo; }
355+
lu_byte& getInstructionsWithAbsRef() noexcept { return iwthabs; }
356356
};
357357

358358

@@ -364,17 +364,17 @@ class ConstantPool {
364364

365365
public:
366366
/* Inline accessors */
367-
inline Table* getCache() const noexcept { return cache; }
368-
inline int getCount() const noexcept { return count; }
367+
Table* getCache() const noexcept { return cache; }
368+
int getCount() const noexcept { return count; }
369369

370-
inline void setCache(Table* cache_) noexcept { cache = cache_; }
371-
inline void setCount(int count_) noexcept { count = count_; }
370+
void setCache(Table* cache_) noexcept { cache = cache_; }
371+
void setCount(int count_) noexcept { count = count_; }
372372

373373
/* Increment */
374-
inline void incrementCount() noexcept { count++; }
374+
void incrementCount() noexcept { count++; }
375375

376376
/* Reference accessor */
377-
inline int& getCountRef() noexcept { return count; }
377+
int& getCountRef() noexcept { return count; }
378378
};
379379

380380

@@ -388,22 +388,22 @@ class VariableScope {
388388

389389
public:
390390
/* Inline accessors */
391-
inline int getFirstLocal() const noexcept { return firstlocal; }
392-
inline int getFirstLabel() const noexcept { return firstlabel; }
393-
inline short getNumDebugVars() const noexcept { return ndebugvars; }
394-
inline short getNumActiveVars() const noexcept { return nactvar; }
391+
int getFirstLocal() const noexcept { return firstlocal; }
392+
int getFirstLabel() const noexcept { return firstlabel; }
393+
short getNumDebugVars() const noexcept { return ndebugvars; }
394+
short getNumActiveVars() const noexcept { return nactvar; }
395395

396-
inline void setFirstLocal(int firstlocal_) noexcept { firstlocal = firstlocal_; }
397-
inline void setFirstLabel(int firstlabel_) noexcept { firstlabel = firstlabel_; }
398-
inline void setNumDebugVars(short ndebugvars_) noexcept { ndebugvars = ndebugvars_; }
399-
inline void setNumActiveVars(short nactvar_) noexcept { nactvar = nactvar_; }
396+
void setFirstLocal(int firstlocal_) noexcept { firstlocal = firstlocal_; }
397+
void setFirstLabel(int firstlabel_) noexcept { firstlabel = firstlabel_; }
398+
void setNumDebugVars(short ndebugvars_) noexcept { ndebugvars = ndebugvars_; }
399+
void setNumActiveVars(short nactvar_) noexcept { nactvar = nactvar_; }
400400

401401
/* Increment */
402-
inline short postIncrementNumDebugVars() noexcept { return ndebugvars++; }
402+
short postIncrementNumDebugVars() noexcept { return ndebugvars++; }
403403

404404
/* Reference accessors */
405-
inline short& getNumDebugVarsRef() noexcept { return ndebugvars; }
406-
inline short& getNumActiveVarsRef() noexcept { return nactvar; }
405+
short& getNumDebugVarsRef() noexcept { return ndebugvars; }
406+
short& getNumActiveVarsRef() noexcept { return nactvar; }
407407
};
408408

409409

@@ -414,14 +414,14 @@ class RegisterAllocator {
414414

415415
public:
416416
/* Inline accessors */
417-
inline lu_byte getFreeReg() const noexcept { return freereg; }
418-
inline void setFreeReg(lu_byte freereg_) noexcept { freereg = freereg_; }
417+
lu_byte getFreeReg() const noexcept { return freereg; }
418+
void setFreeReg(lu_byte freereg_) noexcept { freereg = freereg_; }
419419

420420
/* Decrement */
421-
inline void decrementFreeReg() noexcept { freereg--; }
421+
void decrementFreeReg() noexcept { freereg--; }
422422

423423
/* Reference accessor */
424-
inline lu_byte& getFreeRegRef() noexcept { return freereg; }
424+
lu_byte& getFreeRegRef() noexcept { return freereg; }
425425
};
426426

427427

@@ -433,15 +433,15 @@ class UpvalueTracker {
433433

434434
public:
435435
/* Inline accessors */
436-
inline lu_byte getNumUpvalues() const noexcept { return nups; }
437-
inline lu_byte getNeedClose() const noexcept { return needclose; }
436+
lu_byte getNumUpvalues() const noexcept { return nups; }
437+
lu_byte getNeedClose() const noexcept { return needclose; }
438438

439-
inline void setNumUpvalues(lu_byte nups_) noexcept { nups = nups_; }
440-
inline void setNeedClose(lu_byte needclose_) noexcept { needclose = needclose_; }
439+
void setNumUpvalues(lu_byte nups_) noexcept { nups = nups_; }
440+
void setNeedClose(lu_byte needclose_) noexcept { needclose = needclose_; }
441441

442442
/* Reference accessors */
443-
inline lu_byte& getNumUpvaluesRef() noexcept { return nups; }
444-
inline lu_byte& getNeedCloseRef() noexcept { return needclose; }
443+
lu_byte& getNumUpvaluesRef() noexcept { return nups; }
444+
lu_byte& getNeedCloseRef() noexcept { return needclose; }
445445
};
446446

447447

0 commit comments

Comments
 (0)