Optimize String usage with StringView for basic file paths operations

This commit is contained in:
Wojtek Figat
2021-04-29 23:24:06 +02:00
parent fd595863dc
commit 09671823e4
13 changed files with 84 additions and 86 deletions

View File

@@ -487,7 +487,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options opt
// Auto-import textures
if (autoImportOutput.IsEmpty() || (data.Types & ImportDataTypes::Textures) == 0 || texture.FilePath.IsEmpty())
continue;
auto filename = StringUtils::GetFileNameWithoutExtension(texture.FilePath);
String filename = StringUtils::GetFileNameWithoutExtension(texture.FilePath);
for (int32 j = filename.Length() - 1; j >= 0; j--)
{
if (EditorUtilities::IsInvalidPathChar(filename[j]))
@@ -498,7 +498,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options opt
int32 counter = 1;
do
{
filename = StringUtils::GetFileNameWithoutExtension(texture.FilePath) + TEXT(" ") + StringUtils::ToString(counter);
filename = String(StringUtils::GetFileNameWithoutExtension(texture.FilePath)) + TEXT(" ") + StringUtils::ToString(counter);
counter++;
} while (importedFileNames.Contains(filename));
}