dolphin icon indicating copy to clipboard operation
dolphin copied to clipboard

Modernize range operations

Open tygyh opened this issue 1 year ago • 8 comments

Use std::ranges where possible

tygyh avatar Aug 10 '24 17:08 tygyh

I think this has potential to go further. The ranges versions of standard algorithms can do more than just eliminate the redundant begin() and end() calls when iterating through an entire container. There's also range projections, a useful optional parameter for when only a sub-member is needed. On short notice, I found a blog post that explains how they work if you weren't already aware. Similar to my suggestion for the unused header culling, splitting this into the different sectors of Dolphin's codebase would be helpful for review purposes.

mitaclaw avatar Aug 10 '24 17:08 mitaclaw

Some places where std::as_const was added must be missing the <utility> header. I think using std::as_const isn't necessary, anyway. JetBrains is just trying to uphold the intent of the code originally using cbegin() and cend().

mitaclaw avatar Aug 10 '24 18:08 mitaclaw

@dolphin-emu-bot rebuild.

Do you know how to use clang-format in JetBrains, or are you manually editing to match what the buildbot says is correct? If the latter, I encourage you to stop and figure out how to set up format on save. It will save you a lot of time down the line.

mitaclaw avatar Aug 17 '24 21:08 mitaclaw

Saving with no new changes might not do the formatting needed, so you may need to format the document with a shortcut, e.g. on VS Code it's Ctrl + Shift + I.

mitaclaw avatar Aug 17 '24 21:08 mitaclaw

Are you manually editing to match what the buildbot says is correct?

Yes, I'm having some issues with the automatic formatting. Jetbrains suggests wrong formatting most of the time. I'll look into fixing it later today.

tygyh avatar Aug 18 '24 09:08 tygyh

@dolphin-emu-bot rebuild

mitaclaw avatar Aug 20 '24 16:08 mitaclaw

@tygyh As I mentioned, there is more that can be done with the ranges library which this PR misses out on, and rather than dictating to you over GitHub which changes I want where and how it would be best to split this PR (currently, it is a lot of lines and files changed), I think I would rather take the helm with these proposed changes. Would you be offended if I went ahead with this?

mitaclaw avatar Aug 22 '24 23:08 mitaclaw

Would you be offended if I went ahead with this?

Go ahead,just link to this in the description.

tygyh avatar Aug 24 '24 14:08 tygyh