Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add const references in String class #84375

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/string/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ String String::get_with_code_lines() const {
return ret;
}

int String::get_slice_count(String p_splitter) const {
int String::get_slice_count(const String &p_splitter) const {
if (is_empty()) {
return 0;
}
Expand All @@ -1124,7 +1124,7 @@ int String::get_slice_count(String p_splitter) const {
return slices;
}

String String::get_slice(String p_splitter, int p_slice) const {
String String::get_slice(const String &p_splitter, int p_slice) const {
if (is_empty() || p_splitter.is_empty()) {
return "";
}
Expand Down Expand Up @@ -3495,7 +3495,7 @@ bool String::matchn(const String &p_wildcard) const {
return _wildcard_match(p_wildcard.get_data(), get_data(), false);
}

String String::format(const Variant &values, String placeholder) const {
String String::format(const Variant &values, const String &placeholder) const {
String new_string = String(this->ptr());

if (values.get_type() == Variant::ARRAY) {
Expand Down Expand Up @@ -5167,7 +5167,7 @@ String String::sprintf(const Array &values, bool *error) const {
return formatted;
}

String String::quote(String quotechar) const {
String String::quote(const String &quotechar) const {
return quotechar + *this + quotechar;
}

Expand Down
8 changes: 4 additions & 4 deletions core/string/ustring.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class String {
bool is_quoted() const;
Vector<String> bigrams() const;
float similarity(const String &p_string) const;
String format(const Variant &values, String placeholder = "{_}") const;
String format(const Variant &values, const String &placeholder = "{_}") const;
String replace_first(const String &p_key, const String &p_with) const;
String replace(const String &p_key, const String &p_with) const;
String replace(const char *p_key, const char *p_with) const;
Expand All @@ -315,7 +315,7 @@ class String {
String lpad(int min_length, const String &character = " ") const;
String rpad(int min_length, const String &character = " ") const;
String sprintf(const Array &values, bool *error) const;
String quote(String quotechar = "\"") const;
String quote(const String &quotechar = "\"") const;
String unquote() const;
static String num(double p_num, int p_decimals = -1);
static String num_scientific(double p_num);
Expand Down Expand Up @@ -349,8 +349,8 @@ class String {
String to_snake_case() const;

String get_with_code_lines() const;
int get_slice_count(String p_splitter) const;
String get_slice(String p_splitter, int p_slice) const;
int get_slice_count(const String &p_splitter) const;
String get_slice(const String &p_splitter, int p_slice) const;
String get_slicec(char32_t p_splitter, int p_slice) const;

Vector<String> split(const String &p_splitter = "", bool p_allow_empty = true, int p_maxsplit = 0) const;
Expand Down
Loading