summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2020-02-11 07:53:33 +0100
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2020-02-11 10:29:01 +0100
commit07d21b84a34068bb96fc56a52738ad1ce5233b93 (patch)
treeb9363ae3a3d9f89fa3577193dfc45ba8c5ddb67f /core
parent6fb64054088d0b4da2b35d3d730820550605f7a7 (diff)
Refactor List operator[] to prevent compiler warnings.
Prevents GCC compiler throwing: control reaches end of non-void function. Prevents Visual Studio throwing C4715: not all control paths return a value.
Diffstat (limited to 'core')
-rw-r--r--core/list.h18
1 files changed, 4 insertions, 14 deletions
diff --git a/core/list.h b/core/list.h
index 0796410a84..6250cec598 100644
--- a/core/list.h
+++ b/core/list.h
@@ -456,17 +456,12 @@ public:
Element *I = front();
int c = 0;
- while (I) {
-
- if (c == p_index) {
-
- return I->get();
- }
+ while (c < p_index) {
I = I->next();
c++;
}
- CRASH_NOW(); // bug!!
+ return I->get();
}
const T &operator[](int p_index) const {
@@ -475,17 +470,12 @@ public:
const Element *I = front();
int c = 0;
- while (I) {
-
- if (c == p_index) {
-
- return I->get();
- }
+ while (c < p_index) {
I = I->next();
c++;
}
- CRASH_NOW(); // bug!!
+ return I->get();
}
void move_to_back(Element *p_I) {