Skip to content

Commit 1489854

Browse files
committed
Use more const references when possible
1 parent 2aef09c commit 1489854

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

include/asm/section.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ void sect_ByteString(std::vector<int32_t> const &string);
9191
void sect_WordString(std::vector<int32_t> const &string);
9292
void sect_LongString(std::vector<int32_t> const &string);
9393
void sect_Skip(uint32_t skip, bool ds);
94-
void sect_RelByte(Expression &expr, uint32_t pcShift);
95-
void sect_RelBytes(uint32_t n, std::vector<Expression> &exprs);
96-
void sect_RelWord(Expression &expr, uint32_t pcShift);
97-
void sect_RelLong(Expression &expr, uint32_t pcShift);
98-
void sect_PCRelByte(Expression &expr, uint32_t pcShift);
94+
void sect_RelByte(Expression const &expr, uint32_t pcShift);
95+
void sect_RelBytes(uint32_t n, std::vector<Expression> const &exprs);
96+
void sect_RelWord(Expression const &expr, uint32_t pcShift);
97+
void sect_RelLong(Expression const &expr, uint32_t pcShift);
98+
void sect_PCRelByte(Expression const &expr, uint32_t pcShift);
9999
void sect_BinaryFile(std::string const &name, int32_t startPos);
100100
void sect_BinaryFileSlice(std::string const &name, int32_t startPos, int32_t length);
101101

src/asm/section.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ void sect_Skip(uint32_t skip, bool ds) {
768768
}
769769

770770
// Output a byte that can be relocatable or constant
771-
void sect_RelByte(Expression &expr, uint32_t pcShift) {
771+
void sect_RelByte(Expression const &expr, uint32_t pcShift) {
772772
if (!requireCodeSection()) {
773773
return;
774774
}
@@ -782,15 +782,13 @@ void sect_RelByte(Expression &expr, uint32_t pcShift) {
782782
}
783783

784784
// Output several bytes that can be relocatable or constant
785-
void sect_RelBytes(uint32_t n, std::vector<Expression> &exprs) {
785+
void sect_RelBytes(uint32_t n, std::vector<Expression> const &exprs) {
786786
if (!requireCodeSection()) {
787787
return;
788788
}
789789

790790
for (uint32_t i = 0; i < n; i++) {
791-
Expression &expr = exprs[i % exprs.size()];
792-
793-
if (!expr.isKnown()) {
791+
if (Expression const &expr = exprs[i % exprs.size()]; !expr.isKnown()) {
794792
createPatch(PATCHTYPE_BYTE, expr, i);
795793
writeByte(0);
796794
} else {
@@ -800,7 +798,7 @@ void sect_RelBytes(uint32_t n, std::vector<Expression> &exprs) {
800798
}
801799

802800
// Output a word that can be relocatable or constant
803-
void sect_RelWord(Expression &expr, uint32_t pcShift) {
801+
void sect_RelWord(Expression const &expr, uint32_t pcShift) {
804802
if (!requireCodeSection()) {
805803
return;
806804
}
@@ -814,7 +812,7 @@ void sect_RelWord(Expression &expr, uint32_t pcShift) {
814812
}
815813

816814
// Output a long that can be relocatable or constant
817-
void sect_RelLong(Expression &expr, uint32_t pcShift) {
815+
void sect_RelLong(Expression const &expr, uint32_t pcShift) {
818816
if (!requireCodeSection()) {
819817
return;
820818
}
@@ -828,7 +826,7 @@ void sect_RelLong(Expression &expr, uint32_t pcShift) {
828826
}
829827

830828
// Output a PC-relative byte that can be relocatable or constant
831-
void sect_PCRelByte(Expression &expr, uint32_t pcShift) {
829+
void sect_PCRelByte(Expression const &expr, uint32_t pcShift) {
832830
if (!requireCodeSection()) {
833831
return;
834832
}

0 commit comments

Comments
 (0)