From 97039b55b6e1cbf720e7ceae08339848a52e7740 Mon Sep 17 00:00:00 2001 From: nishinji <107111782+nishinji@users.noreply.github.com> Date: Wed, 27 May 2026 22:30:25 +0900 Subject: [PATCH] util: Use contains instead of find for strings (#3961) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update BUILDING.md * util: Use contains instead of find for strings also removed custom 'bit_cast' Co-authored-by: 双子叶植物 <149964080+Dicot0721@users.noreply.github.com> --------- Co-authored-by: nishinji Co-authored-by: 双子叶植物 <149964080+Dicot0721@users.noreply.github.com> --- .github/CONTRIBUTING.md | 17 +++++- CMakeLists.txt | 2 +- README.md | 2 +- vita3k/compat/src/compat.cpp | 2 +- vita3k/config/src/settings.cpp | 2 +- vita3k/cpu/src/dynarmic_cpu.cpp | 2 +- vita3k/gdbstub/src/gdb.cpp | 1 - vita3k/gui-qt/src/live_area_widget.cpp | 4 +- vita3k/interface.cpp | 10 ++-- vita3k/io/src/io.cpp | 4 +- vita3k/kernel/src/load_self.cpp | 4 +- vita3k/module/src/load_module.cpp | 8 +-- vita3k/modules/SceAppMgr/SceAppMgr.cpp | 2 +- vita3k/modules/SceHttp/SceHttp.cpp | 8 +-- .../SceKernelModulemgr/SceModulemgr.cpp | 2 +- vita3k/modules/SceSysmodule/SceSysmodule.cpp | 2 +- vita3k/net/src/p2psocket.cpp | 3 +- vita3k/ngs/src/ngs.cpp | 2 +- vita3k/ngs/src/route.cpp | 2 +- vita3k/packages/src/pkg.cpp | 2 +- vita3k/patch/src/patch.cpp | 6 +-- vita3k/regmgr/src/regmgr.cpp | 2 +- vita3k/renderer/src/texture/cache.cpp | 1 - vita3k/renderer/src/vulkan/renderer.cpp | 4 +- .../include/shader/usse_constant_table.h | 3 +- vita3k/shader/src/usse_utilities.cpp | 1 - vita3k/util/CMakeLists.txt | 1 - vita3k/util/include/util/bit_cast.h | 38 -------------- vita3k/util/include/util/bytes.h | 12 +++-- vita3k/util/include/util/float_to_half.h | 2 +- vita3k/util/include/util/vector_utils.h | 8 +-- vita3k/util/src/byte.cpp | 52 ------------------- vita3k/util/src/tracy.cpp | 2 +- vita3k/vkutil/include/vkutil/objects.h | 3 +- 34 files changed, 67 insertions(+), 149 deletions(-) delete mode 100644 vita3k/util/include/util/bit_cast.h delete mode 100644 vita3k/util/src/byte.cpp diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 90b3ef467..8907644a2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1 +1,16 @@ -Please see the [Wiki](https://github.com/Vita3K/Vita3K/wiki) for developer information. +# Getting Started +Before getting started using the emulator, read the [Quickstart Guide](https://vita3k.org/quickstart.html). After reading it, if you need support, check out our `help` channel in [discord server](https://discord.gg/MaWhJVH). + +# Issue Reporting +**The GitHub Issue Tracker is not the place to ask for support or to submit[Game Compatibility reports.** Requests for support or incorrect reports will be closed. + +**Before reporting an issue:** +- Check if your system matches all the minimum requirements listed in the [Quickstart Guide](https://vita3k.org/quickstart.html); +- Search older issues threads to see if your issue was already submitted; +- Use understandable English. It doesn't need to be perfect, but clear enough to understand your message; +- While reporting issues, please follow the template for the type of issue you've selected (Bug Report or Feature Request), which is prefilled on the issue's textbox. + +Submitting your test results for Commercial Games must be done on our [Compatibility](https://github.com/Vita3K/compatibility) repo. + +# Contributing +Check the [Coding Style Guidelines](https://github.com/Vita3K/Vita3K/wiki/Coding-style) and [Developer Information](https://github.com/Vita3K/Vita3K/wiki/Developer-Information). If you have any questions, hit us up on our [Discord Server](https://discord.gg/MaWhJVJ) in the **#development** channel. diff --git a/CMakeLists.txt b/CMakeLists.txt index 44ab21220..97c8d3a02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0) -# workaround for SDL due to cmake bug +# workaround for SDL due to cmake bug # https://github.com/libsdl-org/SDL/issues/6454 # https://gitlab.kitware.com/cmake/cmake/-/issues/24104 if(APPLE) diff --git a/README.md b/README.md index 6c1cce56d..13682c0e7 100755 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ You can download the latest builds from [here](https://github.com/Vita3K/Vita3K/ * [vita3k-git](https://aur.archlinux.org/packages/vita3k-git)AUR * Requirements: * xdg-desktop-portal -* [Android](https://github.com/Vita3K/Vita3K-Android/releases/) +* Android * [Adreno drivers](https://github.com/K11MCH1/AdrenoToolsDrivers/releases/) * Others * [Download Artifact](https://github.com/Vita3K/Vita3K/actions?query=event%3Apush+is%3Asuccess+branch%3Amaster) diff --git a/vita3k/compat/src/compat.cpp b/vita3k/compat/src/compat.cpp index a52b24245..d6788ebd8 100644 --- a/vita3k/compat/src/compat.cpp +++ b/vita3k/compat/src/compat.cpp @@ -76,7 +76,7 @@ static bool parse_xml(CompatState &state, const uint8_t *data, size_t size) { const std::string title_id = app.attribute("title_id").as_string(); const uint32_t issue_id = app.child("issue_id").text().as_uint(); - if ((title_id.find("PCS") == std::string::npos) && (title_id != "NPXS10007")) { + if (!title_id.contains("PCS") && (title_id != "NPXS10007")) { LOG_WARN_IF(state.log_compat_warn, "Title ID {} is invalid. Please check GitHub issue {} and verify it!", title_id, issue_id); continue; } diff --git a/vita3k/config/src/settings.cpp b/vita3k/config/src/settings.cpp index 6446ecb10..f89a846e4 100644 --- a/vita3k/config/src/settings.cpp +++ b/vita3k/config/src/settings.cpp @@ -398,7 +398,7 @@ std::vector> get_modules_list( } for (auto &m : modules) - m.second = vector_utils::contains(lle_modules, m.first); + m.second = std::ranges::contains(lle_modules, m.first); std::sort(modules.begin(), modules.end(), [](const auto &a, const auto &b) { if (a.second == b.second) diff --git a/vita3k/cpu/src/dynarmic_cpu.cpp b/vita3k/cpu/src/dynarmic_cpu.cpp index 2fb8a3412..86454712a 100644 --- a/vita3k/cpu/src/dynarmic_cpu.cpp +++ b/vita3k/cpu/src/dynarmic_cpu.cpp @@ -18,7 +18,6 @@ #include "cpu/common.h" #include #include -#include #include #include @@ -27,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/vita3k/gdbstub/src/gdb.cpp b/vita3k/gdbstub/src/gdb.cpp index 12892c730..7ce6868dd 100644 --- a/vita3k/gdbstub/src/gdb.cpp +++ b/vita3k/gdbstub/src/gdb.cpp @@ -18,7 +18,6 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include -#include #include #include diff --git a/vita3k/gui-qt/src/live_area_widget.cpp b/vita3k/gui-qt/src/live_area_widget.cpp index abb4ff6df..f0bb4c059 100644 --- a/vita3k/gui-qt/src/live_area_widget.cpp +++ b/vita3k/gui-qt/src/live_area_widget.cpp @@ -689,7 +689,7 @@ void LiveAreaWidget::mousePressEvent(QMouseEvent *e) { continue; const auto &target = item_it->second.target; - if (target.empty() || target.find("psts:") != std::string::npos) + if (target.empty() || target.contains("psts:")) continue; const auto &fl = fl_it->second; @@ -736,7 +736,7 @@ void LiveAreaWidget::mouseMoveEvent(QMouseEvent *e) { auto item_it = m_frame_items.find(frame.id); if (item_it == m_frame_items.end() || item_it->second.target.empty()) continue; - if (item_it->second.target.find("psts:") != std::string::npos) + if (item_it->second.target.contains("psts:")) continue; const auto &fl = fl_it->second; diff --git a/vita3k/interface.cpp b/vita3k/interface.cpp index a8d63377f..a056523a5 100644 --- a/vita3k/interface.cpp +++ b/vita3k/interface.cpp @@ -118,7 +118,7 @@ static bool set_content_path(EmuEnvState &emuenv, const bool is_theme, fs::path dest_path /= fs::path("addcont") / emuenv.app_info.app_title_id / emuenv.app_info.app_content_id; emuenv.app_info.app_title += " (DLC)"; } - } else if (emuenv.app_info.app_category.find("gp") != std::string::npos) { + } else if (emuenv.app_info.app_category.contains("gp")) { if (!fs::exists(app_path) || fs::is_empty(app_path)) { LOG_ERROR("Install app before patch"); return false; @@ -209,7 +209,7 @@ static bool install_archive_content(EmuEnvState &emuenv, const ZipPtr &zip, cons continue; } const std::string m_filename = file_stat.m_filename; - if (m_filename.find(content_path) != std::string::npos) { + if (m_filename.contains(content_path)) { file_progress = static_cast(i) / num_files * 100.0f; update_progress(); @@ -254,7 +254,7 @@ static std::vector get_archive_contents_path(const ZipPtr &zip) { continue; std::string m_filename = std::string(file_stat.m_filename); - if (m_filename.find("sce_module/steroid.suprx") != std::string::npos) { + if (m_filename.contains("sce_module/steroid.suprx")) { LOG_CRITICAL("A Vitamin dump was detected, aborting installation..."); #ifdef __ANDROID__ // SDL_ShowAndroidToast("Vitamin dumps are not supported!", 1, -1, 0, 0); @@ -263,9 +263,9 @@ static std::vector get_archive_contents_path(const ZipPtr &zip) { break; } - const auto is_content = (m_filename.find(sfo_path) != std::string::npos) || (m_filename.find(theme_path) != std::string::npos); + const auto is_content = m_filename.contains(sfo_path) || m_filename.contains(theme_path); if (is_content) { - const auto content_type = (m_filename.find(sfo_path) != std::string::npos) ? sfo_path : theme_path; + const auto content_type = m_filename.contains(sfo_path) ? sfo_path : theme_path; m_filename.erase(m_filename.find(content_type)); vector_utils::push_if_not_exists(content_path, m_filename); } diff --git a/vita3k/io/src/io.cpp b/vita3k/io/src/io.cpp index d60b625ab..23a355c2c 100644 --- a/vita3k/io/src/io.cpp +++ b/vita3k/io/src/io.cpp @@ -287,7 +287,7 @@ std::string translate_path(const char *path, VitaIoDevice &device, const IOState return std::string{}; } default: { - LOG_CRITICAL_IF(relative_path.find(':') != std::string::npos, "Unknown device with path {} used. Report this to the developers!", relative_path); + LOG_CRITICAL_IF(relative_path.contains(':'), "Unknown device with path {} used. Report this to the developers!", relative_path); return std::string{}; } } @@ -783,7 +783,7 @@ SceUID read_dir(IOState &io, const SceUID fd, SceIoDirent *dent, const fs::path bool copy_path(const fs::path &src_path, const fs::path &pref_path, const std::string &app_title_id, const std::string &app_category) { // Check if is path - if (app_category.find("gp") != std::string::npos) { + if (app_category.contains("gp")) { const auto app_path{ pref_path / "ux0/app" / app_title_id }; const auto result = fs_utils::copy_directory_contents(src_path, app_path); diff --git a/vita3k/kernel/src/load_self.cpp b/vita3k/kernel/src/load_self.cpp index 7252ae555..f74e43829 100644 --- a/vita3k/kernel/src/load_self.cpp +++ b/vita3k/kernel/src/load_self.cpp @@ -632,7 +632,7 @@ SceUID load_self(KernelState &kernel, MemState &mem, const void *self, const std for (auto &patch : patches) { // TODO patches should maybe be able to specify the path/file to patch? - if (seg_index == patch.seg && self_path.find("eboot.bin") != std::string::npos) { + if (seg_index == patch.seg && self_path.contains("eboot.bin")) { LOG_INFO("Patching segment {} at offset 0x{:X} with {} values", seg_index, patch.offset, patch.values.size()); memcpy(seg_ptr.get(mem) + patch.offset, patch.values.data(), patch.values.size()); } @@ -749,7 +749,7 @@ SceUID load_self(KernelState &kernel, MemState &mem, const void *self, const std sceKernelModuleInfo->state = module_info->type; LOG_INFO("Linking SELF {}...", self_path); - if (self_path.find("eboot.bin") != std::string::npos) + if (self_path.contains("eboot.bin")) LOG_INFO("eboot.bin module NID: {}", log_hex(module_info->module_nid)); if (!load_exports(sceKernelModuleInfo, *module_info, module_info_segment_address, kernel, mem)) { diff --git a/vita3k/module/src/load_module.cpp b/vita3k/module/src/load_module.cpp index 704c715d3..4e74dd4eb 100644 --- a/vita3k/module/src/load_module.cpp +++ b/vita3k/module/src/load_module.cpp @@ -168,13 +168,13 @@ bool is_lle_module(SceSysmoduleModuleId module_id, EmuEnvState &emuenv) { if (have_paths) { if (emuenv.cfg.current_config.modules_mode != ModulesMode::MANUAL) { - if (vector_utils::contains(auto_lle_modules, module_id)) + if (std::ranges::contains(auto_lle_modules, module_id)) return true; } if (emuenv.cfg.current_config.modules_mode != ModulesMode::AUTOMATIC) { for (auto path : paths) { - if (vector_utils::contains(emuenv.cfg.current_config.lle_modules, path)) + if (std::ranges::contains(emuenv.cfg.current_config.lle_modules, path)) return true; } } @@ -198,11 +198,11 @@ bool is_lle_module(const std::string &module_name, EmuEnvState &emuenv) { if (auto_lle_module_names.empty()) auto_lle_module_names = init_auto_lle_module_names(); if (emuenv.cfg.current_config.modules_mode != ModulesMode::AUTOMATIC) { - if (vector_utils::contains(emuenv.cfg.current_config.lle_modules, module_name)) + if (std::ranges::contains(emuenv.cfg.current_config.lle_modules, module_name)) return true; } if (emuenv.cfg.current_config.modules_mode != ModulesMode::MANUAL) { - if (vector_utils::contains(auto_lle_module_names, module_name)) + if (std::ranges::contains(auto_lle_module_names, module_name)) return true; } return false; diff --git a/vita3k/modules/SceAppMgr/SceAppMgr.cpp b/vita3k/modules/SceAppMgr/SceAppMgr.cpp index 88f8461c8..828c45e34 100644 --- a/vita3k/modules/SceAppMgr/SceAppMgr.cpp +++ b/vita3k/modules/SceAppMgr/SceAppMgr.cpp @@ -411,7 +411,7 @@ EXPORT(SceInt32, _sceAppMgrLoadExec, const char *appPath, Ptr const argv[] // Create exec path auto exec_path = static_cast(appPath); - if (exec_path.find("app0:/") != std::string::npos) + if (exec_path.contains("app0:/")) exec_path.erase(0, 6); else exec_path.erase(0, 5); diff --git a/vita3k/modules/SceHttp/SceHttp.cpp b/vita3k/modules/SceHttp/SceHttp.cpp index 1fdb1421d..78511b046 100644 --- a/vita3k/modules/SceHttp/SceHttp.cpp +++ b/vita3k/modules/SceHttp/SceHttp.cpp @@ -838,7 +838,7 @@ EXPORT(SceInt, sceHttpParseStatusLine, const char *statusLine, SceSize lineLen, return RET_ERROR(SCE_HTTP_ERROR_PARSE_HTTP_INVALID_RESPONSE); *httpMajorVer = string_utils::stoi_def(version.substr(0, version.find('.'))); // we know this wont fail because parseStatusLine returned true :) - if (version.find('.') != std::string::npos) { + if (version.contains('.')) { auto minorVer = version.substr(version.find('.') + 1); *httpMinorVer = string_utils::stoi_def(minorVer); } else { @@ -1098,15 +1098,15 @@ EXPORT(SceInt, sceHttpSendRequest, SceInt reqId, const char *postData, SceSize s } totalReceived += bytes; - } while (std::string_view(resHeaders).find("\r\n\r\n") == std::string::npos || totalReceived == resHeadersMaxSize); // receive headers until we start receiving body + } while (!std::string_view(resHeaders).contains("\r\n\r\n") || totalReceived == resHeadersMaxSize); // receive headers until we start receiving body - if (totalReceived != resHeadersMaxSize && std::string_view(resHeaders).find("\r\n\r\n") == std::string::npos) { + if (totalReceived != resHeadersMaxSize && !std::string_view(resHeaders).contains("\r\n\r\n")) { delete[] resHeaders; return RET_ERROR(SCE_HTTP_ERROR_TIMEOUT); } // Headers are too big - if (totalReceived == resHeadersMaxSize && std::string_view(resHeaders).find("\r\n\r\n") == std::string::npos) { + if (totalReceived == resHeadersMaxSize && !std::string_view(resHeaders).contains("\r\n\r\n")) { delete[] resHeaders; return RET_ERROR(SCE_HTTP_ERROR_TOO_LARGE_RESPONSE_HEADER); } diff --git a/vita3k/modules/SceKernelModulemgr/SceModulemgr.cpp b/vita3k/modules/SceKernelModulemgr/SceModulemgr.cpp index 7dd7078f6..53571dee1 100644 --- a/vita3k/modules/SceKernelModulemgr/SceModulemgr.cpp +++ b/vita3k/modules/SceKernelModulemgr/SceModulemgr.cpp @@ -64,7 +64,7 @@ static int kernel_stop_module(EmuEnvState &emuenv, SceUID module_id, SceSize arg EXPORT(SceUID, _sceKernelLoadStartModule, const char *moduleFileName, SceSize args, Ptr argp, SceUInt32 flags, const SceKernelLMOption *pOpt, int *pRes) { TRACY_FUNC(_sceKernelLoadStartModule, moduleFileName, args, argp, flags, pOpt, pRes); // Is workaround for fix crash on loading "rgpluginsgm_psvita" module, relate issue #1095 on github, delete this after fix it. - if (std::string_view(moduleFileName).find("rgpluginsgm_psvita") != std::string::npos) { + if (std::string_view(moduleFileName).contains("rgpluginsgm_psvita")) { LOG_WARN("Bypass load this module: {}", moduleFileName); return SCE_KERNEL_ERROR_MODULEMGR_INVALID_TYPE; } diff --git a/vita3k/modules/SceSysmodule/SceSysmodule.cpp b/vita3k/modules/SceSysmodule/SceSysmodule.cpp index 79ca8b022..f0563a559 100644 --- a/vita3k/modules/SceSysmodule/SceSysmodule.cpp +++ b/vita3k/modules/SceSysmodule/SceSysmodule.cpp @@ -186,7 +186,7 @@ EXPORT(int, sceSysmoduleIsLoadedInternal, SceSysmoduleInternalModuleId module_id return RET_ERROR(SCE_SYSMODULE_ERROR_INVALID_VALUE); std::lock_guard guard(emuenv.kernel.mutex); - if (vector_utils::contains(emuenv.kernel.loaded_internal_sysmodules, module_id)) + if (std::ranges::contains(emuenv.kernel.loaded_internal_sysmodules, module_id)) return SCE_SYSMODULE_LOADED; else return RET_ERROR(SCE_SYSMODULE_ERROR_UNLOADED); diff --git a/vita3k/net/src/p2psocket.cpp b/vita3k/net/src/p2psocket.cpp index c24ced633..cefa80199 100644 --- a/vita3k/net/src/p2psocket.cpp +++ b/vita3k/net/src/p2psocket.cpp @@ -16,7 +16,8 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include -#include + +#include static SceNetSockaddr convertP2PToPosix(const SceNetSockaddr *addr) { if (!addr) { diff --git a/vita3k/ngs/src/ngs.cpp b/vita3k/ngs/src/ngs.cpp index dc0ee8969..1d37129df 100644 --- a/vita3k/ngs/src/ngs.cpp +++ b/vita3k/ngs/src/ngs.cpp @@ -219,7 +219,7 @@ bool Voice::remove_patch(const MemState &mem, const Ptr patch) { const std::lock_guard guard(*voice_mutex); bool found = false; for (auto &patches_1 : patches) { - if (vector_utils::contains(patches_1, patch)) { + if (std::ranges::contains(patches_1, patch)) { found = true; break; } diff --git a/vita3k/ngs/src/route.cpp b/vita3k/ngs/src/route.cpp index 0c0084fad..fff200705 100644 --- a/vita3k/ngs/src/route.cpp +++ b/vita3k/ngs/src/route.cpp @@ -33,7 +33,7 @@ bool deliver_data(const MemState &mem, const std::vector &voice_queue, continue; Voice *dest = patch->dest.get(mem); - if (!dest || !vector_utils::contains(voice_queue, dest)) + if (!dest || !std::ranges::contains(voice_queue, dest)) continue; const std::lock_guard guard(*dest->voice_mutex); diff --git a/vita3k/packages/src/pkg.cpp b/vita3k/packages/src/pkg.cpp index 64af24f60..41b890eab 100644 --- a/vita3k/packages/src/pkg.cpp +++ b/vita3k/packages/src/pkg.cpp @@ -67,7 +67,7 @@ bool decrypt_install_nonpdrm(EmuEnvState &emuenv, const fs::path &drmlicpath, co if ((execute(zRIF, title_id_src, title_id_dst, f00d_enc_type, f00d_arg) < 0) && (title_path.string().find("theme") == std::string::npos)) return false; - if (emuenv.app_info.app_category.find("gp") == std::string::npos) + if (!emuenv.app_info.app_category.contains("gp")) copy_license(emuenv, drmlicpath); fs::remove_all(title_id_src); diff --git a/vita3k/patch/src/patch.cpp b/vita3k/patch/src/patch.cpp index 2816138a9..a3b3b488b 100644 --- a/vita3k/patch/src/patch.cpp +++ b/vita3k/patch/src/patch.cpp @@ -32,9 +32,9 @@ std::vector get_patches(fs::path &path, const std::string &titleid, const // Just in case users decide to use lowercase filenames std::transform(filename.begin(), filename.end(), filename.begin(), ::toupper); - bool is_patchlist = filename.find("PATCHLIST.TXT") != std::string::npos; + bool is_patchlist = filename.contains("PATCHLIST.TXT"); - if ((filename.find(titleid) != std::string::npos && filename.ends_with(".TXT")) || is_patchlist) { + if ((filename.contains(titleid) && filename.ends_with(".TXT")) || is_patchlist) { // Read the file std::ifstream file(entry.path().c_str()); PatchHeader patch_header = PatchHeader{ @@ -56,7 +56,7 @@ std::vector get_patches(fs::path &path, const std::string &titleid, const // Ignore comments and patches for other binaries // And @ lines for now - if (line.empty() || line[0] == '#' || line[0] == '@' || bin.find(patch_header.bin) == std::string::npos || (is_patchlist && patch_header.titleid != titleid)) + if (line.empty() || line[0] == '#' || line[0] == '@' || !bin.contains(patch_header.bin) || (is_patchlist && patch_header.titleid != titleid)) continue; try { diff --git a/vita3k/regmgr/src/regmgr.cpp b/vita3k/regmgr/src/regmgr.cpp index fc8b81b15..a610ba4b7 100644 --- a/vita3k/regmgr/src/regmgr.cpp +++ b/vita3k/regmgr/src/regmgr.cpp @@ -67,7 +67,7 @@ static void init_reg_template(RegMgrState ®mgr, const std::string ®) { continue; // Found the base register - if (line.find("[BASE") != std::string::npos) { + if (line.contains("[BASE")) { // Register the names with their numbers while (std::getline(iss, line) && (line != "[REG-BAS")) { if (line.empty()) diff --git a/vita3k/renderer/src/texture/cache.cpp b/vita3k/renderer/src/texture/cache.cpp index d49788f6a..9f9d92717 100644 --- a/vita3k/renderer/src/texture/cache.cpp +++ b/vita3k/renderer/src/texture/cache.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/vita3k/renderer/src/vulkan/renderer.cpp b/vita3k/renderer/src/vulkan/renderer.cpp index 4f2fe5bcf..390d39cf3 100644 --- a/vita3k/renderer/src/vulkan/renderer.cpp +++ b/vita3k/renderer/src/vulkan/renderer.cpp @@ -98,7 +98,7 @@ static void debug_log_message(std::string_view msg) { bool log_error = true; for (auto ignored_error : ignored_errors) { - if (msg.find(ignored_error) != std::string_view::npos) { + if (msg.contains(ignored_error)) { log_error = false; break; } @@ -977,7 +977,7 @@ void VKState::late_init(const Config &cfg, const std::string_view game_id, MemSt #if defined(__linux__) && !defined(__ANDROID__) // According to my tests (Macdu), mprotect on buffers (mapped with external memory host) only works with Nvidia drivers surface_cache.can_mprotect_mapped_memory = mapping_method == MappingMethod::DoubleBuffer - || std::string_view(physical_device_properties.deviceName).find("NVIDIA") != std::string_view::npos; + || std::string_view(physical_device_properties.deviceName).contains("NVIDIA"); #endif pipeline_cache.init(support_rasterized_order_access); diff --git a/vita3k/shader/include/shader/usse_constant_table.h b/vita3k/shader/include/shader/usse_constant_table.h index 17d6daaae..bf263565b 100644 --- a/vita3k/shader/include/shader/usse_constant_table.h +++ b/vita3k/shader/include/shader/usse_constant_table.h @@ -17,8 +17,7 @@ #pragma once -#include - +#include #include namespace shader::usse { diff --git a/vita3k/shader/src/usse_utilities.cpp b/vita3k/shader/src/usse_utilities.cpp index b5c32de23..8ae6b3912 100644 --- a/vita3k/shader/src/usse_utilities.cpp +++ b/vita3k/shader/src/usse_utilities.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include diff --git a/vita3k/util/CMakeLists.txt b/vita3k/util/CMakeLists.txt index f2c617bf5..8418b4208 100644 --- a/vita3k/util/CMakeLists.txt +++ b/vita3k/util/CMakeLists.txt @@ -3,7 +3,6 @@ add_library( STATIC src/android_driver.cpp src/arm.cpp - src/byte.cpp src/float_to_half.cpp src/fs_utils.cpp src/hash.cpp diff --git a/vita3k/util/include/util/bit_cast.h b/vita3k/util/include/util/bit_cast.h deleted file mode 100644 index 6eaa984ec..000000000 --- a/vita3k/util/include/util/bit_cast.h +++ /dev/null @@ -1,38 +0,0 @@ -// Vita3K emulator project -// Copyright (C) 2026 Vita3K team -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -#pragma once - -#include -#include -#include - -#ifndef __cpp_lib_bit_cast -namespace std { -// https://en.cppreference.com/w/cpp/numeric/bit_cast -template -std::enable_if_t bit_cast(const From &src) noexcept { - if constexpr (alignof(From) >= alignof(To)) { - return *reinterpret_cast(&src); - } else { - alignas(alignof(To)) char dst[sizeof(To)]; - std::memcpy(&dst, &src, sizeof(To)); - return *reinterpret_cast(&dst); - } -} -} // namespace std -#endif diff --git a/vita3k/util/include/util/bytes.h b/vita3k/util/include/util/bytes.h index a4207826d..264bc6bf2 100644 --- a/vita3k/util/include/util/bytes.h +++ b/vita3k/util/include/util/bytes.h @@ -18,18 +18,20 @@ #pragma once #include -#include +#include -template -T byte_swap(T val); +template +T byte_swap(T val) { + return std::byteswap(val); +} -template +template T network_to_host_order(T val) { static_assert(((std::endian::native == std::endian::big) || (std::endian::native == std::endian::little)), "Mixed endian is unsupported"); if constexpr (std::endian::native == std::endian::big) { return val; } else { - return byte_swap(val); + return std::byteswap(val); } } diff --git a/vita3k/util/include/util/float_to_half.h b/vita3k/util/include/util/float_to_half.h index 66cba67cb..e4dde10ae 100644 --- a/vita3k/util/include/util/float_to_half.h +++ b/vita3k/util/include/util/float_to_half.h @@ -20,9 +20,9 @@ // original source:https://stackoverflow.com/questions/1659440/32-bit-to-16-bit-floating-point-conversion // public domain -#include "util/bit_cast.h" #include "util/warning.h" +#include // bit_cast #include // CHAR_BIT #include // uint32_t, uint64_t, etc. #include // numeric_limits diff --git a/vita3k/util/include/util/vector_utils.h b/vita3k/util/include/util/vector_utils.h index 49d2313fe..e9ca88cb9 100644 --- a/vita3k/util/include/util/vector_utils.h +++ b/vita3k/util/include/util/vector_utils.h @@ -57,8 +57,7 @@ size_t find_index(const T &v, const V &value) { template bool push_if_not_exists(T &v, const V &value) { - auto it = std::find(v.begin(), v.end(), value); - if (it == v.end()) { + if (!std::ranges::contains(v, value)) { v.push_back(value); return false; } else { @@ -66,11 +65,6 @@ bool push_if_not_exists(T &v, const V &value) { } } -template -bool contains(const T &v, const V &value) { - return std::find(v.begin(), v.end(), value) != v.end(); -} - template bool erase_first(T &v, const V &value) { auto it = std::find(v.begin(), v.end(), value); diff --git a/vita3k/util/src/byte.cpp b/vita3k/util/src/byte.cpp deleted file mode 100644 index 9d1b8d795..000000000 --- a/vita3k/util/src/byte.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Vita3K emulator project -// Copyright (C) 2026 Vita3K team -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -#include - -template <> -uint16_t byte_swap(uint16_t val) { - return (val >> 8) | (val << 8); -} - -template <> -uint32_t byte_swap(uint32_t val) { - // AA BB00 CC0000 DD000000 - return (val >> 24) | ((val >> 8) & 0xFF00) | ((val << 8) & 0xFF0000) | ((val << 24) & 0xFF000000); -} - -template <> -uint64_t byte_swap(uint64_t val) { - val = ((val << 8) & 0xFF00FF00FF00FF00ULL) | ((val >> 8) & 0x00FF00FF00FF00FFULL); - val = ((val << 16) & 0xFFFF0000FFFF0000ULL) | ((val >> 16) & 0x0000FFFF0000FFFFULL); - - return (val << 32) | (val >> 32); -} - -template <> -int16_t byte_swap(int16_t val) { - return byte_swap(static_cast(val)); -} - -template <> -int32_t byte_swap(int32_t val) { - return byte_swap(static_cast(val)); -} - -template <> -int64_t byte_swap(int64_t val) { - return byte_swap(static_cast(val)); -} diff --git a/vita3k/util/src/tracy.cpp b/vita3k/util/src/tracy.cpp index a8f3ed128..3919dc493 100644 --- a/vita3k/util/src/tracy.cpp +++ b/vita3k/util/src/tracy.cpp @@ -83,7 +83,7 @@ void load_from(const std::vector &active_modules_str) { void cleanup(std::vector &active_modules_str) { // remove if not found in tracy_available_advanced_profiling_modules std::erase_if(active_modules_str, [](const std::string &module) { - return !vector_utils::contains(get_tracy_available_advanced_profiling_modules(), module); + return !std::ranges::contains(get_tracy_available_advanced_profiling_modules(), module); }); } diff --git a/vita3k/vkutil/include/vkutil/objects.h b/vita3k/vkutil/include/vkutil/objects.h index c9c834902..81ce13b5f 100644 --- a/vita3k/vkutil/include/vkutil/objects.h +++ b/vita3k/vkutil/include/vkutil/objects.h @@ -17,9 +17,10 @@ #pragma once -#include #include +#include + namespace vkutil { void init(vma::Allocator vma_allocator);