mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Add String::replace_char(s) methods for performance and convenience
This commit is contained in:
@@ -146,7 +146,7 @@ Error DirAccess::make_dir_recursive(const String &p_dir) {
|
||||
full_dir = p_dir;
|
||||
}
|
||||
|
||||
full_dir = full_dir.replace("\\", "/");
|
||||
full_dir = full_dir.replace_char('\\', '/');
|
||||
|
||||
String base;
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ FileAccess::AccessType FileAccess::get_access_type() const {
|
||||
String FileAccess::fix_path(const String &p_path) const {
|
||||
// Helper used by file accesses that use a single filesystem.
|
||||
|
||||
String r_path = p_path.replace("\\", "/");
|
||||
String r_path = p_path.replace_char('\\', '/');
|
||||
|
||||
switch (_access_type) {
|
||||
case ACCESS_RESOURCES: {
|
||||
|
||||
@@ -548,7 +548,7 @@ String DirAccessPack::get_drive(int p_drive) {
|
||||
}
|
||||
|
||||
PackedData::PackedDir *DirAccessPack::_find_dir(const String &p_dir) {
|
||||
String nd = p_dir.replace("\\", "/");
|
||||
String nd = p_dir.replace_char('\\', '/');
|
||||
|
||||
// Special handling since simplify_path() will forbid it
|
||||
if (p_dir == "..") {
|
||||
|
||||
@@ -2294,7 +2294,7 @@ void Image::initialize_data(const char **p_xpm) {
|
||||
switch (status) {
|
||||
case READING_HEADER: {
|
||||
String line_str = line_ptr;
|
||||
line_str.replace("\t", " ");
|
||||
line_str.replace_char('\t', ' ');
|
||||
|
||||
size_width = line_str.get_slicec(' ', 0).to_int();
|
||||
size_height = line_str.get_slicec(' ', 1).to_int();
|
||||
|
||||
@@ -155,7 +155,7 @@ void RotatedFileLogger::rotate_file() {
|
||||
|
||||
if (FileAccess::exists(base_path)) {
|
||||
if (max_files > 1) {
|
||||
String timestamp = Time::get_singleton()->get_datetime_string_from_system().replace(":", ".");
|
||||
String timestamp = Time::get_singleton()->get_datetime_string_from_system().replace_char(':', '.');
|
||||
String backup_name = base_path.get_basename() + timestamp;
|
||||
if (!base_path.get_extension().is_empty()) {
|
||||
backup_name += "." + base_path.get_extension();
|
||||
|
||||
Reference in New Issue
Block a user