From eecd03428ddf915495fda42e7ca1211458785b22 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 29 Mar 2020 21:09:30 -0400 Subject: [PATCH] CSortedLists: Remove use of const_cast in AddToLinkedList() Same behavior, but nicer to read. --- Runtime/CSortedLists.cpp | 12 +++++++----- Runtime/CSortedLists.hpp | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Runtime/CSortedLists.cpp b/Runtime/CSortedLists.cpp index e22c0166e..0f4954256 100644 --- a/Runtime/CSortedLists.cpp +++ b/Runtime/CSortedLists.cpp @@ -30,17 +30,19 @@ void CSortedListManager::Reset() { } } -void CSortedListManager::AddToLinkedList(s16 nodeId, s16& headId, s16& tailId) const { +void CSortedListManager::AddToLinkedList(s16 nodeId, s16& headId, s16& tailId) { if (headId == -1) { - const_cast(AccessElement(x0_nodes, nodeId)).x28_next = headId; + AccessElement(x0_nodes, nodeId).x28_next = headId; headId = nodeId; tailId = nodeId; } else { - if (AccessElement(x0_nodes, nodeId).x28_next != -1) + if (AccessElement(x0_nodes, nodeId).x28_next != -1) { return; - if (tailId == nodeId) + } + if (tailId == nodeId) { return; - const_cast(AccessElement(x0_nodes, nodeId)).x28_next = headId; + } + AccessElement(x0_nodes, nodeId).x28_next = headId; headId = nodeId; } } diff --git a/Runtime/CSortedLists.hpp b/Runtime/CSortedLists.hpp index f251ff662..9b14ff706 100644 --- a/Runtime/CSortedLists.hpp +++ b/Runtime/CSortedLists.hpp @@ -31,7 +31,7 @@ class CSortedListManager { std::array x0_nodes; std::array xb000_sortedLists; void Reset(); - void AddToLinkedList(s16 a, s16& b, s16& c) const; + void AddToLinkedList(s16 a, s16& b, s16& c); void RemoveFromList(ESortedList, s16); void MoveInList(ESortedList, s16); void InsertInList(ESortedList, SNode& node);