[release/8.0] Make a copy of assembly path. (#93253)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Thu, 12 Oct 2023 00:01:03 +0000 (17:01 -0700)
committerGitHub <noreply@github.com>
Thu, 12 Oct 2023 00:01:03 +0000 (17:01 -0700)
* Make a copy of assembly path.

* Use correct C++.

* Use copy ctor explicitly

---------

Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
src/coreclr/vm/perfinfo.cpp

index 0be2e519936fbea45acc6c550d90414c7913e297..98fc667661a504261a891ce1325c7e345ab5806f 100644 (file)
@@ -32,8 +32,8 @@ void PerfInfo::LogImage(PEAssembly* pPEAssembly, CHAR* guid)
         PRECONDITION(guid != nullptr);
     } CONTRACTL_END;
 
-    SString value;
-    const SString& path = pPEAssembly->GetPath();
+    // Nothing to log if the assembly path isn't present.
+    SString path{ pPEAssembly->GetPath() };
     if (path.IsEmpty())
     {
         return;
@@ -49,12 +49,11 @@ void PerfInfo::LogImage(PEAssembly* pPEAssembly, CHAR* guid)
         }
     }
 
+    SString value;
     value.Printf("%s%c%s%c%p", path.GetUTF8(), sDelimiter, guid, sDelimiter, baseAddr);
 
-    SString command;
-    command.Printf("%s", "ImageLoad");
+    SString command{ SString::Literal, "ImageLoad" };
     WriteLine(command, value);
-
 }
 
 // Writes a command line, with "type" being the type of command, with "value" as the command's corresponding instructions/values. This is to be used to log specific information, e.g. LogImage