Reduce string allocations in ProfileCompilationInfo.

Use std::string_view internally to avoid std::string
allocations but keep external ProfileCompilationInfo API
unchanged with std::string to avoid object lifetime issues,
with the exception of `OfflineProfileMethodInfo` provided
to the compiler for AOT compilation.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: boots.
Bug: 181943478
Change-Id: If75c3ce16581760773bdaa3e94334c9c567745de
diff --git a/runtime/jit/profiling_info_test.cc b/runtime/jit/profiling_info_test.cc
index 319a3e1..efaea84 100644
--- a/runtime/jit/profiling_info_test.cc
+++ b/runtime/jit/profiling_info_test.cc
@@ -172,9 +172,14 @@
         dex_pc_data.AddClass(dex_profile_index, class_ref.TypeIndex());
         if (dex_profile_index >= offline_pmi.dex_references.size()) {
           // This is a new dex.
-          const std::string& dex_key = ProfileCompilationInfo::GetProfileDexFileBaseKey(
-              class_ref.dex_file->GetLocation());
-          offline_pmi.dex_references.emplace_back(dex_key,
+          const std::string& location = class_ref.dex_file->GetLocation();
+          std::string dex_key = ProfileCompilationInfo::GetProfileDexFileBaseKey(location);
+          // The `dex_key` is a temporary that shall cease to exist soon. Create a view
+          // using the dex file's location as the backing data.
+          CHECK(EndsWith(location, dex_key));
+          size_t dex_key_start = location.size() - dex_key.size();
+          std::string_view dex_key_view(location.data() + dex_key_start, dex_key.size());
+          offline_pmi.dex_references.emplace_back(dex_key_view,
                                                   class_ref.dex_file->GetLocationChecksum(),
                                                   class_ref.dex_file->NumMethodIds());
         }