Merge pull request #57562 from AnilBK/string-add-contains

String: Add contains().
This commit is contained in:
Rémi Verschelde 2022-02-03 22:21:24 +01:00 committed by GitHub
commit f8f19b313d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 142 additions and 119 deletions

View file

@ -99,11 +99,11 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String
if (reading_versions) {
String l = line.strip_edges();
if (!l.is_empty()) {
if (l.find("=") == -1) {
if (!l.contains("=")) {
base_error = "Missing `=` in '" + l + "'. Version syntax is `version = \"<defines with C escaping>\";`.";
break;
}
if (l.find(";") == -1) {
if (!l.contains(";")) {
// We don't require a semicolon per se, but it's needed for clang-format to handle things properly.
base_error = "Missing `;` in '" + l + "'. Version syntax is `version = \"<defines with C escaping>\";`.";
break;

View file

@ -182,7 +182,7 @@ static String _mkid(const String &p_id) {
static String f2sp0(float p_float) {
String num = rtoss(p_float);
if (num.find(".") == -1 && num.find("e") == -1) {
if (!num.contains(".") && !num.contains("e")) {
num += ".0";
}
return num;