use bare array instead of parray in tournament index

This commit is contained in:
Martin Michelsen
2022-12-08 01:06:00 -08:00
parent 9a1ba56982
commit 9bb168b693
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -395,7 +395,7 @@ void Tournament::print_bracket(FILE* stream) const {
vector<shared_ptr<Tournament>> TournamentIndex::all_tournaments() const { vector<shared_ptr<Tournament>> TournamentIndex::all_tournaments() const {
vector<shared_ptr<Tournament>> ret; vector<shared_ptr<Tournament>> ret;
for (size_t z = 0; z < this->tournaments.size(); z++) { for (size_t z = 0; z < 0x20; z++) {
if (this->tournaments[z]) { if (this->tournaments[z]) {
ret.emplace_back(this->tournaments[z]); ret.emplace_back(this->tournaments[z]);
} }
@@ -412,12 +412,12 @@ shared_ptr<Tournament> TournamentIndex::create_tournament(
bool is_2v2) { bool is_2v2) {
// Find an unused tournament number // Find an unused tournament number
uint8_t number; uint8_t number;
for (number = 0; number < this->tournaments.size(); number++) { for (number = 0; number < 0x20; number++) {
if (!this->tournaments[number]) { if (!this->tournaments[number]) {
break; break;
} }
} }
if (number >= this->tournaments.size()) { if (number >= 0x20) {
throw runtime_error("all tournament slots are full"); throw runtime_error("all tournament slots are full");
} }
@@ -436,7 +436,7 @@ shared_ptr<Tournament> TournamentIndex::get_tournament(uint8_t number) const {
} }
shared_ptr<Tournament> TournamentIndex::get_tournament(const string& name) const { shared_ptr<Tournament> TournamentIndex::get_tournament(const string& name) const {
for (size_t z = 0; z < this->tournaments.size(); z++) { for (size_t z = 0; z < 0x20; z++) {
if (this->tournaments[z] && (this->tournaments[z]->get_name() == name)) { if (this->tournaments[z] && (this->tournaments[z]->get_name() == name)) {
return this->tournaments[z]; return this->tournaments[z];
} }
+1 -1
View File
@@ -156,7 +156,7 @@ public:
std::shared_ptr<Tournament> get_tournament(const std::string& name) const; std::shared_ptr<Tournament> get_tournament(const std::string& name) const;
private: private:
parray<std::shared_ptr<Tournament>, 0x20> tournaments; std::shared_ptr<Tournament> tournaments[0x20];
}; };