Skip to content

[Draft] Full removal of nall::vector#2200

Closed
rasky wants to merge 18 commits intoares-emulator:masterfrom
rasky:nall7
Closed

[Draft] Full removal of nall::vector#2200
rasky wants to merge 18 commits intoares-emulator:masterfrom
rasky:nall7

Conversation

@rasky
Copy link
Copy Markdown
Collaborator

@rasky rasky commented Sep 4, 2025

This draft PR shows the whole road to nall::vector removal. It will be submitted as smaller PRs one at a time until we reach the end, so this just shows the final version of the series.

@rasky rasky marked this pull request as draft September 4, 2025 13:11
@rasky rasky force-pushed the nall7 branch 14 times, most recently from 7fbf2dc to c37d072 Compare September 5, 2025 15:16
@rasky rasky requested a review from Copilot September 5, 2025 15:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This draft PR demonstrates the complete removal of nall::vector, replacing it with std::vector throughout the codebase. This represents a significant modernization effort to use standard library containers instead of custom implementations.

  • Complete replacement of nall::vector with std::vector across all modules
  • Updating method calls from nall-specific APIs to standard library equivalents
  • Adding necessary vector-helpers.hpp to provide compatibility functions
  • Removing all nall::vector implementation files and dependencies

Reviewed Changes

Copilot reviewed 290 out of 290 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
nall/nall/vector-helpers.hpp New helper functions to replace vector-specific operations like split/merge
tools/mame2bml/mame2bml.cpp Updated vector usage and method calls
tools/genius/genius.hpp Changed vector types to std::vector
nall/nall/vector.hpp Removed entire nall::vector implementation
mia/mia.cpp Updated media list to use std::vector
desktop-ui/emulator/emulator.hpp Changed emulator collections to std::vector
ares/*/system/system.cpp Updated enumerate functions to return std::vector

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.
Comment on lines 34 to 36
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.

This pattern of extracting front/back elements and erasing them appears multiple times. Consider creating helper functions like take_front() and take_back() to reduce code duplication.

Copilot uses AI. Check for mistakes.
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.
Comment on lines 36 to 37
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 while loop repeatedly calls push_back which may cause multiple reallocations. Consider using resize for better performance: if(index >= link.size()) link.resize(index + 1, nullptr);

Suggested change
auto set_link(u32 index, Node* node) -> void {
while(index >= link.size()) link.push_back(nullptr);
if(index >= link.size()) link.resize(index + 1, nullptr);

Copilot uses AI. Check for mistakes.
@rasky rasky force-pushed the nall7 branch 2 times, most recently from 6e0e056 to 70fd1ee Compare September 14, 2025 07:41
genius can't build with Qt as it uses ComboEdit, but it is currently
enabled in the ubuntu-ci-qt as it inherits the base ubuntu-ci (which is
GTK-based).
- Replace all nall::vector declarations with std::vector in desktop-ui
- Update API calls: .append() -> .push_back(), .reset() -> .clear()
- Replace .takeFirst()/.takeLast() with .front()/.back() + .erase()/.pop_back()
- Convert .find() to std::ranges::find() and std::ranges::find_if()
- Replace .sort() with std::ranges::sort()
- Fix boolean conversions: if(!vector) -> if(vector.empty())
- Migrate all emulator-specific files and core desktop-ui components
- Use direct assignments between std::vector instead of manual loops
- Maintain compatibility with nall::split() by using auto type deduction
@rasky
Copy link
Copy Markdown
Collaborator Author

rasky commented Sep 14, 2025

Superseded by #2218

@rasky rasky closed this Sep 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants