Avoided a string copy by using path view

Signed-off-by: srikappa-amzn <srikappa@amazon.com>
This commit is contained in:
srikappa-amzn
2021-10-21 11:42:41 -07:00
parent 4ed73a0b91
commit 33490ed6df
2 changed files with 6 additions and 4 deletions
@@ -2651,11 +2651,12 @@ namespace AzToolsFramework
AZ::IO::FixedMaxPath lexicallyNormalPath = AZ::IO::PathView(slicePath.toUtf8().constData()).LexicallyNormal();
bool isPathSafeForAssets = false;
for (AZ::IO::Path assetSafeFolder : assetSafeFolders)
for (const AZStd::string& assetSafeFolder : assetSafeFolders)
{
AZ::IO::PathView assetSafeFolderView(assetSafeFolder);
// Check if the slice path is relative to the safe asset directory.
// The Path classes are being used to make this check case insensitive.
if (lexicallyNormalPath.IsRelativeTo(assetSafeFolder))
if (lexicallyNormalPath.IsRelativeTo(assetSafeFolderView))
{
isPathSafeForAssets = true;
break;
@@ -803,11 +803,12 @@ namespace AzToolsFramework
AZ::IO::FixedMaxPath lexicallyNormalPath = AZ::IO::PathView(prefabPath.toUtf8().constData()).LexicallyNormal();
bool isPathSafeForAssets = false;
for (AZ::IO::Path assetSafeFolder : assetSafeFolders)
for (const AZStd::string& assetSafeFolder : assetSafeFolders)
{
AZ::IO::PathView assetSafeFolderView(assetSafeFolder);
// Check if the prefabPath is relative to the safe asset directory.
// The Path classes are being used to make this check case insensitive.
if (lexicallyNormalPath.IsRelativeTo(assetSafeFolder))
if (lexicallyNormalPath.IsRelativeTo(assetSafeFolderView))
{
isPathSafeForAssets = true;
break;