mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-24 06:14:54 +00:00
Replace find(x) != npos
with contains(x)
- Core
This commit is contained in:
parent
fc0179c1ea
commit
43abd74221
14 changed files with 41 additions and 47 deletions
|
@ -724,9 +724,8 @@ static bool Unpack(const std::function<bool()>& cancelled, const std::string pat
|
|||
|
||||
// Check for path traversal attacks.
|
||||
const bool is_path_traversal_attack =
|
||||
(childname.find("\\") != std::string_view::npos) ||
|
||||
(childname.find('/') != std::string_view::npos) ||
|
||||
std::ranges::all_of(childname, [](char c) { return c == '.'; });
|
||||
(childname.contains('\\')) || (childname.contains('/')) ||
|
||||
std::ranges::all_of(childname, [](char c) { return c == '.'; });
|
||||
if (is_path_traversal_attack)
|
||||
{
|
||||
ERROR_LOG_FMT(
|
||||
|
|
|
@ -34,16 +34,15 @@ u32 GetMemoryTargetSize(std::string_view instr)
|
|||
constexpr char PAIRED_TAG = 'p';
|
||||
|
||||
// Actual range is 0 to size - 1;
|
||||
if (op.find(BYTE_TAG) != std::string::npos)
|
||||
if (op.contains(BYTE_TAG))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (op.find(HALF_TAG) != std::string::npos)
|
||||
else if (op.contains(HALF_TAG))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (op.find(DOUBLE_WORD_TAG) != std::string::npos ||
|
||||
op.find(PAIRED_TAG) != std::string::npos)
|
||||
else if (op.contains(DOUBLE_WORD_TAG) || op.contains(PAIRED_TAG))
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ MemoryCard::MemoryCard(const std::string& filename, ExpansionInterface::Slot car
|
|||
// Fills in the first 5 blocks (MC_HDR_SIZE bytes)
|
||||
auto& sram = Core::System::GetInstance().GetSRAM();
|
||||
const CardFlashId& flash_id = sram.settings_ex.flash_id[Memcard::SLOT_A];
|
||||
const bool shift_jis = m_filename.find(".JAP.raw") != std::string::npos;
|
||||
const bool shift_jis = m_filename.contains(".JAP.raw");
|
||||
const u32 rtc_bias = sram.settings.rtc_bias;
|
||||
const u32 sram_language = static_cast<u32>(sram.settings.language);
|
||||
const u64 format_time =
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
for (const SaveFile& file : m_files_list)
|
||||
{
|
||||
// files in subdirs are deleted automatically when the subdir is deleted
|
||||
if (file.path.find('/') != std::string::npos)
|
||||
if (file.path.contains('/'))
|
||||
continue;
|
||||
|
||||
const auto result =
|
||||
|
|
|
@ -103,7 +103,7 @@ static u64 FixupDirectoryEntries(File::FSTEntry* dir, bool is_root)
|
|||
|
||||
// Decode escaped invalid file system characters so that games (such as Harry Potter and the
|
||||
// Half-Blood Prince) can find what they expect.
|
||||
if (it->virtualName.find("__") != std::string::npos)
|
||||
if (it->virtualName.contains("__"))
|
||||
it->virtualName = Common::UnescapeFileName(it->virtualName);
|
||||
|
||||
// Drop files that have too long filenames.
|
||||
|
|
|
@ -231,10 +231,10 @@ static bool DecompressPacketIntoFolderInternal(sf::Packet& packet, const std::st
|
|||
std::string name;
|
||||
packet >> name;
|
||||
|
||||
if (name.find('/') != std::string::npos)
|
||||
if (name.contains('/'))
|
||||
return false;
|
||||
#ifdef _WIN32
|
||||
if (name.find('\\') != std::string::npos)
|
||||
if (name.contains('\\'))
|
||||
return false;
|
||||
#endif
|
||||
if (std::ranges::all_of(name, [](char c) { return c == '.'; }))
|
||||
|
|
|
@ -92,10 +92,10 @@ void BreakPoints::AddFromStrings(const TBreakPointsStr& bp_strings)
|
|||
iss.ignore();
|
||||
iss >> std::hex >> bp.address;
|
||||
iss >> flags;
|
||||
bp.is_enabled = flags.find('n') != flags.npos;
|
||||
bp.log_on_hit = flags.find('l') != flags.npos;
|
||||
bp.break_on_hit = flags.find('b') != flags.npos;
|
||||
if (flags.find('c') != std::string::npos)
|
||||
bp.is_enabled = flags.contains('n');
|
||||
bp.log_on_hit = flags.contains('l');
|
||||
bp.break_on_hit = flags.contains('b');
|
||||
if (flags.contains('c'))
|
||||
{
|
||||
iss >> std::ws;
|
||||
std::string condition;
|
||||
|
@ -266,12 +266,12 @@ void MemChecks::AddFromStrings(const TMemChecksStr& mc_strings)
|
|||
iss >> std::hex >> mc.start_address >> mc.end_address >> flags;
|
||||
|
||||
mc.is_ranged = mc.start_address != mc.end_address;
|
||||
mc.is_enabled = flags.find('n') != flags.npos;
|
||||
mc.is_break_on_read = flags.find('r') != flags.npos;
|
||||
mc.is_break_on_write = flags.find('w') != flags.npos;
|
||||
mc.log_on_hit = flags.find('l') != flags.npos;
|
||||
mc.break_on_hit = flags.find('b') != flags.npos;
|
||||
if (flags.find('c') != std::string::npos)
|
||||
mc.is_enabled = flags.contains('n');
|
||||
mc.is_break_on_read = flags.contains('r');
|
||||
mc.is_break_on_write = flags.contains('w');
|
||||
mc.log_on_hit = flags.contains('l');
|
||||
mc.break_on_hit = flags.contains('b');
|
||||
if (flags.contains('c'))
|
||||
{
|
||||
iss >> std::ws;
|
||||
std::string condition;
|
||||
|
|
|
@ -142,8 +142,7 @@ static double CallstackFunc(expr_func* f, vec_expr_t* args, void* c)
|
|||
const char* cstr = expr_get_str(&vec_nth(args, 0));
|
||||
if (cstr != nullptr)
|
||||
{
|
||||
return std::ranges::any_of(
|
||||
stack, [cstr](const auto& s) { return s.Name.find(cstr) != std::string::npos; });
|
||||
return std::ranges::any_of(stack, [cstr](const auto& s) { return s.Name.contains(cstr); });
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -62,7 +62,7 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ
|
|||
#ifdef _WIN32
|
||||
// Riivolution treats a backslash as just a standard filename character, but we can't replicate
|
||||
// this properly on Windows. So if a file contains a backslash, immediately error out.
|
||||
if (external_relative_path.find("\\") != std::string_view::npos)
|
||||
if (external_relative_path.contains("\\"))
|
||||
return std::nullopt;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ void XRRConfiguration::Update()
|
|||
unsigned int fullWidth, fullHeight;
|
||||
char* output_name = nullptr;
|
||||
char auxFlag = '\0';
|
||||
if (fullscreen_display_res.find(':') == std::string::npos)
|
||||
if (!fullscreen_display_res.contains(':'))
|
||||
{
|
||||
fullWidth = fb_width;
|
||||
fullHeight = fb_height;
|
||||
|
|
|
@ -244,13 +244,13 @@ void Metal::Util::PopulateBackendInfoFeatures(const VideoConfig& config, Backend
|
|||
// Initialize DriverDetails first so we can use it later
|
||||
DriverDetails::Vendor vendor = DriverDetails::VENDOR_UNKNOWN;
|
||||
std::string name = [[device name] UTF8String];
|
||||
if (name.find("NVIDIA") != std::string::npos)
|
||||
if (name.contains("NVIDIA"))
|
||||
vendor = DriverDetails::VENDOR_NVIDIA;
|
||||
else if (name.find("AMD") != std::string::npos)
|
||||
else if (name.contains("AMD"))
|
||||
vendor = DriverDetails::VENDOR_ATI;
|
||||
else if (name.find("Intel") != std::string::npos)
|
||||
else if (name.contains("Intel"))
|
||||
vendor = DriverDetails::VENDOR_INTEL;
|
||||
else if (name.find("Apple") != std::string::npos)
|
||||
else if (name.contains("Apple"))
|
||||
vendor = DriverDetails::VENDOR_APPLE;
|
||||
const NSOperatingSystemVersion cocoa_ver = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
double version = cocoa_ver.majorVersion * 100 + cocoa_ver.minorVersion;
|
||||
|
|
|
@ -53,11 +53,11 @@ void InitDriverInfo()
|
|||
{
|
||||
vendor = DriverDetails::VENDOR_ATI;
|
||||
}
|
||||
else if (sversion.find("Mesa") != std::string::npos)
|
||||
else if (sversion.contains("Mesa"))
|
||||
{
|
||||
vendor = DriverDetails::VENDOR_MESA;
|
||||
}
|
||||
else if (svendor.find("Intel") != std::string::npos)
|
||||
else if (svendor.contains("Intel"))
|
||||
{
|
||||
vendor = DriverDetails::VENDOR_INTEL;
|
||||
}
|
||||
|
@ -121,13 +121,12 @@ void InitDriverInfo()
|
|||
else if (svendor == "Intel Open Source Technology Center")
|
||||
{
|
||||
driver = DriverDetails::DRIVER_I965;
|
||||
if (srenderer.find("Sandybridge") != std::string::npos)
|
||||
if (srenderer.contains("Sandybridge"))
|
||||
family = DriverDetails::Family::INTEL_SANDY;
|
||||
else if (srenderer.find("Ivybridge") != std::string::npos)
|
||||
else if (srenderer.contains("Ivybridge"))
|
||||
family = DriverDetails::Family::INTEL_IVY;
|
||||
}
|
||||
else if (srenderer.find("AMD") != std::string::npos ||
|
||||
srenderer.find("ATI") != std::string::npos)
|
||||
else if (srenderer.contains("AMD") || srenderer.contains("ATI"))
|
||||
{
|
||||
driver = DriverDetails::DRIVER_R600;
|
||||
}
|
||||
|
|
|
@ -515,7 +515,7 @@ void VulkanContext::PopulateBackendInfoFeatures(BackendInfo* backend_info, VkPhy
|
|||
|
||||
// Only Apple family GPUs support framebuffer fetch.
|
||||
// We currently use a hacked MoltenVK to implement this, so don't attempt outside of MVK
|
||||
if (is_moltenvk && (vendor_id == 0x106B || device_name.find("Apple") != std::string::npos))
|
||||
if (is_moltenvk && (vendor_id == 0x106B || device_name.contains("Apple")))
|
||||
{
|
||||
backend_info->bSupportsFramebufferFetch = true;
|
||||
}
|
||||
|
@ -980,12 +980,11 @@ void VulkanContext::InitDriverDetails()
|
|||
vendor = DriverDetails::VENDOR_NVIDIA;
|
||||
driver = DriverDetails::DRIVER_NVIDIA;
|
||||
}
|
||||
else if (vendor_id == 0x1002 || vendor_id == 0x1022 ||
|
||||
device_name.find("AMD") != std::string::npos)
|
||||
else if (vendor_id == 0x1002 || vendor_id == 0x1022 || device_name.contains("AMD"))
|
||||
{
|
||||
// RADV always advertises its name in the device string.
|
||||
// If not RADV, assume the AMD binary driver.
|
||||
if (device_name.find("RADV") != std::string::npos)
|
||||
if (device_name.contains("RADV"))
|
||||
{
|
||||
vendor = DriverDetails::VENDOR_MESA;
|
||||
driver = DriverDetails::DRIVER_R600;
|
||||
|
@ -996,8 +995,7 @@ void VulkanContext::InitDriverDetails()
|
|||
driver = DriverDetails::DRIVER_ATI;
|
||||
}
|
||||
}
|
||||
else if (vendor_id == 0x8086 || vendor_id == 0x8087 ||
|
||||
device_name.find("Intel") != std::string::npos)
|
||||
else if (vendor_id == 0x8086 || vendor_id == 0x8087 || device_name.contains("Intel"))
|
||||
{
|
||||
// Apart from the driver version, Intel does not appear to provide a way to
|
||||
// differentiate between anv and the binary driver (Skylake+). Assume to be
|
||||
|
@ -1010,25 +1008,25 @@ void VulkanContext::InitDriverDetails()
|
|||
driver = DriverDetails::DRIVER_I965;
|
||||
#endif
|
||||
}
|
||||
else if (vendor_id == 0x5143 || device_name.find("Adreno") != std::string::npos)
|
||||
else if (vendor_id == 0x5143 || device_name.contains("Adreno"))
|
||||
{
|
||||
// Currently only the Qualcomm binary driver exists for Adreno.
|
||||
vendor = DriverDetails::VENDOR_QUALCOMM;
|
||||
driver = DriverDetails::DRIVER_QUALCOMM;
|
||||
}
|
||||
else if (vendor_id == 0x13B6 || device_name.find("Mali") != std::string::npos)
|
||||
else if (vendor_id == 0x13B6 || device_name.contains("Mali"))
|
||||
{
|
||||
// Currently only the ARM binary driver exists for Mali.
|
||||
vendor = DriverDetails::VENDOR_ARM;
|
||||
driver = DriverDetails::DRIVER_ARM;
|
||||
}
|
||||
else if (vendor_id == 0x1010 || device_name.find("PowerVR") != std::string::npos)
|
||||
else if (vendor_id == 0x1010 || device_name.contains("PowerVR"))
|
||||
{
|
||||
// Currently only the binary driver exists for PowerVR.
|
||||
vendor = DriverDetails::VENDOR_IMGTEC;
|
||||
driver = DriverDetails::DRIVER_IMGTEC;
|
||||
}
|
||||
else if (device_name.find("Apple") != std::string::npos)
|
||||
else if (device_name.contains("Apple"))
|
||||
{
|
||||
vendor = DriverDetails::VENDOR_APPLE;
|
||||
driver = DriverDetails::DRIVER_PORTABILITY;
|
||||
|
|
|
@ -278,7 +278,7 @@ bool PixelShaderData::FromJson(const VideoCommon::CustomAssetLibrary::AssetID& a
|
|||
|
||||
for (const auto& [name, property] : data->m_properties)
|
||||
{
|
||||
if (data->m_shader_source.find(name) == std::string::npos)
|
||||
if (!data->m_shader_source.contains(name))
|
||||
{
|
||||
ERROR_LOG_FMT(
|
||||
VIDEO,
|
||||
|
|
Loading…
Add table
Reference in a new issue