Remove CStr::Find(CStr)

It was only a wrapper around `std::string::find`. In some places it's
now better to use `std::string::starts_with`.
This commit is contained in:
phosit
2026-08-23 17:07:27 +02:00
parent 45ea0432a2
commit 982ede2a55
7 changed files with 17 additions and 47 deletions
-12
View File
@@ -264,17 +264,6 @@ double CStr::ToDouble() const
return ret;
}
// Search the string for another string
long CStr::Find(const CStr& str) const
{
size_t pos = find(str, 0);
if (pos != npos)
return static_cast<long>(pos);
return -1;
}
// Search the string for another string
long CStr::Find(const Char chr) const
{
@@ -299,7 +288,6 @@ long CStr::Find(const int start, const Char chr) const
long CStr::FindInsensitive(const int start, const Char chr) const { return LowerCase().Find(start, totlower(chr)); }
long CStr::FindInsensitive(const Char chr) const { return LowerCase().Find(totlower(chr)); }
long CStr::FindInsensitive(const CStr& str) const { return LowerCase().Find(str.LowerCase()); }
long CStr::ReverseFind(const CStr& str) const
{
-18
View File
@@ -138,15 +138,6 @@ public:
**/
double ToDouble() const;
/**
* Search the CStr for another string.
* The search is case-sensitive.
*
* @param const CStr & str reference to the search string
* @return long offset into the CStr of the first occurrence of the search string
* -1 if the search string is not found
**/
long Find(const CStr& str) const;
/**
* Search the CStr for another string.
* The search is case-sensitive.
@@ -167,15 +158,6 @@ public:
**/
long Find(const int start, const Char chr) const;
/**
* Search the CStr for another string.
* The search is case-insensitive.
*
* @param const CStr & str reference to the search string
* @return long offset into the CStr of the first occurrence of the search string
* -1 if the search string is not found
**/
long FindInsensitive(const CStr& str) const;
/**
* Search the CStr for another string.
* The search is case-insensitive.
+5 -5
View File
@@ -334,8 +334,8 @@ std::vector<CStr> Mod::CheckForIncompatibleMods(const std::vector<CStr>& mods) c
// 0ad<=0.0.24
for (const CStr& op : toCheck)
{
const int pos = dep.Find(op.c_str());
if (pos == -1)
const std::size_t pos{dep.find(op)};
if (pos == std::string::npos)
continue;
//0ad
const CStr modToCheck = dep.substr(0, pos);
@@ -364,9 +364,9 @@ bool Mod::CompareVersionStrings(const CStr& version, const CStr& op, const CStr&
boost::split(versionSplit, versionSplit[0], boost::is_any_of("."), boost::token_compress_on);
boost::split(requiredSplit, requiredSplit[0], boost::is_any_of("."), boost::token_compress_on);
const bool eq = op.Find("=") != -1;
const bool lt = op.Find("<") != -1;
const bool gt = op.Find(">") != -1;
const bool eq = op.find("=") != std::string::npos;
const bool lt = op.find("<") != std::string::npos;
const bool gt = op.find(">") != std::string::npos;
const size_t min = std::min(versionSplit.size(), requiredSplit.size());