Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stdc++: migrate tools/tests removing uses of nall::vector
  • Loading branch information
rasky committed Sep 14, 2025
commit 77eb8a0b3986fe1242bf566caeff806927499a9f
10 changes: 5 additions & 5 deletions tests/arm7tdmi/arm7tdmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct TestCase {
u32 index;
TestState initial;
TestState final;
vector<Transaction> transactions;
std::vector<Transaction> transactions;
u32 opcode;
u32 base_addr;
};
Expand All @@ -56,14 +56,14 @@ using TestResults = array<u32[3]>;
struct CPU : ares::ARM7TDMI {
u32 clock = 0;
int tindex = 0;
vector<string> errors;
std::vector<string> errors;
maybe<const TestCase&> test;

auto power(const TestCase& test) -> void {
ARM7TDMI::power();
clock = 0;
tindex = 0;
errors.reset();
errors.clear();
this->test = test;
}

Expand Down Expand Up @@ -131,7 +131,7 @@ struct CPU : ares::ARM7TDMI {

template<typename... P>
auto error(P&&... p) -> void {
errors.append(string{std::forward<P>(p)...});
errors.push_back(string{std::forward<P>(p)...});
}
} cpu;

Expand Down Expand Up @@ -333,7 +333,7 @@ auto CPU::run(const TestCase& test, bool logErrors) -> TestResult {
error("transactions: ", tindex, " != ", test.transactions.size(), "\n");
}

if(errors) {
if(!errors.empty()) {
if(logErrors) {
print("\n");
print("test: ", test.index, "\n");
Expand Down
8 changes: 4 additions & 4 deletions tests/m68000/m68000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct TestState {
u32 usp;
u32 ssp;
array<u32[2]> prefetch;
vector<array<u32[2]>> ram;
std::vector<array<u32[2]>> ram;
};

struct TestCase {
Expand Down Expand Up @@ -101,9 +101,9 @@ auto CPU::run(const TestCase& test, bool logErrors) -> TestResult {

instruction();

vector<string> errors;
std::vector<string> errors;
auto error = [&](auto&&... p) -> void {
errors.append(string{std::forward<decltype(p)>(p)...});
errors.push_back(string{std::forward<decltype(p)>(p)...});
Comment on lines 104 to 106
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lambda captures by reference but creates temporary string objects. Consider using emplace_back instead of push_back to construct the string in place: errors.emplace_back(std::forward<decltype(p)>(p)...);

Copilot uses AI. Check for mistakes.
};

if(!r.s) swap(r.a[7], r.sp); //swap back to match test format
Expand Down Expand Up @@ -148,7 +148,7 @@ auto CPU::run(const TestCase& test, bool logErrors) -> TestResult {
}
}

if(errors) {
if(!errors.empty()) {
if(logErrors) {
print("\n");
print(test.name, "\n");
Expand Down
2 changes: 1 addition & 1 deletion tools/genius/genius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ auto ListWindow::updateWindow() -> void {
removeButton.setEnabled((bool)gameList.selected());
string name = Location::base(location);
if(!name) name = "(Untitled)";
setTitle({modified ? "*" : "", name, " [", games.size(), "] - genius"});
setTitle({modified ? "*" : string{}, name, " [", games.size(), "] - genius"});
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ternary operator creates an unnecessary temporary string object. Consider using an empty string literal instead: modified ? "*" : \"\"

Suggested change
setTitle({modified ? "*" : string{}, name, " [", games.size(), "] - genius"});
setTitle({modified ? "*" : "", name, " [", games.size(), "] - genius"});

Copilot uses AI. Check for mistakes.
}

auto ListWindow::newDatabase() -> void {
Expand Down
11 changes: 7 additions & 4 deletions tools/mame2bml/mame2bml.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <nall/nall.hpp>
#include <algorithm>
#include <ranges>
#include <vector>

using namespace nall;

Expand All @@ -19,14 +22,14 @@ auto Mame2BML::main(Arguments arguments) -> void {

string markupName = arguments.take();
string outputName = arguments.take();
vector<string> driverNames = {};
std::vector<string> driverNames = {};
if(!markupName.endsWith(".xml")) return print("error: arguments in incorrect order\n");
if(!outputName.endsWith(".bml")) return print("error: arguments in incorrect order\n");
if(arguments.size() == 0) return print("error: mame driver or ares core name required\n");

while(arguments.size()) {
string driverName = arguments.take();
driverNames.append(driverName);
driverNames.push_back(driverName);
}

string markup = string::read(markupName);
Expand All @@ -53,7 +56,7 @@ auto Mame2BML::main(Arguments arguments) -> void {
for(auto machine : header) {
if(machine.name() != "machine") continue;
string driverName = machine["sourcefile"].string();
if(!driverNames.find(driverName)) continue;
if(std::ranges::find(driverNames, driverName) == driverNames.end()) continue;
string type = "game";
string IsBIOS = machine["isbios"].string();
string parent = machine["romof"].string();
Expand Down Expand Up @@ -98,7 +101,7 @@ auto Mame2BML::main(Arguments arguments) -> void {
output.print("game\n");
output.print(" name: ", software["name"].string(), "\n");
output.print(" title: ", software["description"].string(), "\n");
output.print(" board: ", driverNames.first(), "\n");
output.print(" board: ", driverNames.front(), "\n");

print("found ", software["name"].string(), " (", software["description"].string(), ")\n");

Expand Down