Skip to content

Commit 543b10a

Browse files
committed
More consistent use of string_view instead of char* for literals
1 parent 199460c commit 543b10a

File tree

10 files changed

+128
-114
lines changed

10 files changed

+128
-114
lines changed

src/native/clr/host/assembly-store.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ auto AssemblyStore::get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData co
2929
#if defined (HAVE_LZ4) && defined (RELEASE)
3030
auto header = reinterpret_cast<const CompressedAssemblyHeader*>(e.image_data);
3131
if (header->magic == COMPRESSED_DATA_MAGIC) {
32-
log_debug (LOG_ASSEMBLY, "Decompressing assembly '{}' from the assembly store", name);
32+
log_debug (LOG_ASSEMBLY, "Decompressing assembly '{}' from the assembly store"sv, name);
3333

3434
if (FastTiming::enabled ()) [[unlikely]] {
3535
internal_timing.start_event (TimingEventKind::AssemblyDecompression);
@@ -42,7 +42,7 @@ auto AssemblyStore::get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData co
4242
Helpers::abort_application (
4343
LOG_ASSEMBLY,
4444
std::format (
45-
"Invalid compressed assembly descriptor index {}",
45+
"Invalid compressed assembly descriptor index {}"sv,
4646
header->descriptor_index
4747
)
4848
);
@@ -71,7 +71,7 @@ auto AssemblyStore::get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData co
7171
Helpers::abort_application (
7272
LOG_ASSEMBLY,
7373
std::format (
74-
"Invalid compressed assembly descriptor at {}: no data",
74+
"Invalid compressed assembly descriptor at {}: no data"sv,
7575
header->descriptor_index
7676
)
7777
);
@@ -82,14 +82,14 @@ auto AssemblyStore::get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData co
8282
Helpers::abort_application (
8383
LOG_ASSEMBLY,
8484
std::format (
85-
"Compressed assembly '{}' is larger than when the application was built (expected at most {}, got {}). Assemblies don't grow just like that!",
85+
"Compressed assembly '{}' is larger than when the application was built (expected at most {}, got {}). Assemblies don't grow just like that!"sv,
8686
name,
8787
cad.uncompressed_file_size,
8888
header->uncompressed_length
8989
)
9090
);
9191
} else {
92-
log_debug (LOG_ASSEMBLY, "Compressed assembly '{}' is smaller than when the application was built. Adjusting accordingly.", name);
92+
log_debug (LOG_ASSEMBLY, "Compressed assembly '{}' is smaller than when the application was built. Adjusting accordingly."sv, name);
9393
}
9494
cad.uncompressed_file_size = header->uncompressed_length;
9595
}
@@ -101,7 +101,7 @@ auto AssemblyStore::get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData co
101101
Helpers::abort_application (
102102
LOG_ASSEMBLY,
103103
std::format (
104-
"Decompression of assembly {} failed with code {}",
104+
"Decompression of assembly {} failed with code {}"sv,
105105
name,
106106
ret
107107
)
@@ -112,7 +112,7 @@ auto AssemblyStore::get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData co
112112
Helpers::abort_application (
113113
LOG_ASSEMBLY,
114114
std::format (
115-
"Decompression of assembly {} yielded a different size (expected {}, got {})",
115+
"Decompression of assembly {} yielded a different size (expected {}, got {})"sv,
116116
name,
117117
cad.uncompressed_file_size,
118118
static_cast<uint32_t>(ret)
@@ -130,12 +130,12 @@ auto AssemblyStore::get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData co
130130
} else
131131
#endif // def HAVE_LZ4 && def RELEASE
132132
{
133-
log_debug (LOG_ASSEMBLY, "Assembly '{}' is not compressed in the assembly store", name);
133+
log_debug (LOG_ASSEMBLY, "Assembly '{}' is not compressed in the assembly store"sv, name);
134134

135135
// HACK! START
136136
// Currently, MAUI crashes when we return a pointer to read-only data, so we must copy
137137
// the assembly data to a read-write area.
138-
log_debug (LOG_ASSEMBLY, "Copying assembly data to an r/w memory area");
138+
log_debug (LOG_ASSEMBLY, "Copying assembly data to an r/w memory area"sv);
139139

140140
if (FastTiming::enabled ()) [[unlikely]] {
141141
internal_timing.start_event (TimingEventKind::AssemblyLoad);
@@ -176,29 +176,29 @@ auto AssemblyStore::find_assembly_store_entry (hash_t hash, const AssemblyStoreI
176176
auto AssemblyStore::open_assembly (std::string_view const& name, int64_t &size) noexcept -> void*
177177
{
178178
hash_t name_hash = xxhash::hash (name.data (), name.length ());
179-
log_debug (LOG_ASSEMBLY, "AssemblyStore::open_assembly: looking for bundled name: '{}' (hash {:x})", optional_string (name.data ()), name_hash);
179+
log_debug (LOG_ASSEMBLY, "AssemblyStore::open_assembly: looking for bundled name: '{}' (hash {:x})"sv, optional_string (name.data ()), name_hash);
180180

181181
if constexpr (Constants::is_debug_build) {
182182
// TODO: implement filesystem lookup here
183183

184184
// In fastdev mode we might not have any assembly store.
185185
if (assembly_store_hashes == nullptr) {
186-
log_warn (LOG_ASSEMBLY, "Assembly store not registered. Unable to look up assembly '{}'", name);
186+
log_warn (LOG_ASSEMBLY, "Assembly store not registered. Unable to look up assembly '{}'"sv, name);
187187
return nullptr;
188188
}
189189
}
190190

191191
const AssemblyStoreIndexEntry *hash_entry = find_assembly_store_entry (name_hash, assembly_store_hashes, assembly_store.index_entry_count);
192192
if (hash_entry == nullptr) {
193-
log_warn (LOG_ASSEMBLY, "Assembly '{}' (hash 0x{:x}) not found", optional_string (name.data ()), name_hash);
193+
log_warn (LOG_ASSEMBLY, "Assembly '{}' (hash 0x{:x}) not found"sv, optional_string (name.data ()), name_hash);
194194
return nullptr;
195195
}
196196

197197
if (hash_entry->descriptor_index >= assembly_store.assembly_count) {
198198
Helpers::abort_application (
199199
LOG_ASSEMBLY,
200200
std::format (
201-
"Invalid assembly descriptor index {}, exceeds the maximum value of {}",
201+
"Invalid assembly descriptor index {}, exceeds the maximum value of {}"sv,
202202
hash_entry->descriptor_index,
203203
assembly_store.assembly_count - 1
204204
)
@@ -219,7 +219,7 @@ auto AssemblyStore::open_assembly (std::string_view const& name, int64_t &size)
219219

220220
log_debug (
221221
LOG_ASSEMBLY,
222-
"Mapped: image_data == {:p}; debug_info_data == {:p}; config_data == {:p}; descriptor == {:p}; data size == {}; debug data size == {}; config data size == {}; name == '{}'",
222+
"Mapped: image_data == {:p}; debug_info_data == {:p}; config_data == {:p}; descriptor == {:p}; data size == {}; debug data size == {}; config data size == {}; name == '{}'"sv,
223223
static_cast<void*>(assembly_runtime_info.image_data),
224224
static_cast<void*>(assembly_runtime_info.debug_info_data),
225225
static_cast<void*>(assembly_runtime_info.config_data),
@@ -241,7 +241,7 @@ void AssemblyStore::map (int fd, std::string_view const& apk_path, std::string_v
241241
detail::mmap_info assembly_store_map = Util::mmap_file (fd, offset, size, store_path);
242242

243243
auto [payload_start, payload_size] = Util::get_wrapper_dso_payload_pointer_and_size (assembly_store_map, store_path);
244-
log_debug (LOG_ASSEMBLY, "Adjusted assembly store pointer: {:p}; size: {}", payload_start, payload_size);
244+
log_debug (LOG_ASSEMBLY, "Adjusted assembly store pointer: {:p}; size: {}"sv, payload_start, payload_size);
245245
auto header = static_cast<AssemblyStoreHeader*>(payload_start);
246246

247247
auto get_full_store_path = [&apk_path, &store_path]() -> std::string {
@@ -263,7 +263,7 @@ void AssemblyStore::map (int fd, std::string_view const& apk_path, std::string_v
263263
Helpers::abort_application (
264264
LOG_ASSEMBLY,
265265
std::format (
266-
"Assembly store '{}' is not a valid .NET for Android assembly store file",
266+
"Assembly store '{}' is not a valid .NET for Android assembly store file"sv,
267267
get_full_store_path ()
268268
)
269269
);
@@ -273,7 +273,7 @@ void AssemblyStore::map (int fd, std::string_view const& apk_path, std::string_v
273273
Helpers::abort_application (
274274
LOG_ASSEMBLY,
275275
std::format (
276-
"Assembly store '{}' uses format version {:x}, instead of the expected {:x}",
276+
"Assembly store '{}' uses format version {:x}, instead of the expected {:x}"sv,
277277
get_full_store_path (),
278278
header->version,
279279
ASSEMBLY_STORE_FORMAT_VERSION
@@ -289,5 +289,5 @@ void AssemblyStore::map (int fd, std::string_view const& apk_path, std::string_v
289289
assembly_store.assemblies = reinterpret_cast<AssemblyStoreEntryDescriptor*>(assembly_store.data_start + header_size + header->index_size);
290290
assembly_store_hashes = reinterpret_cast<AssemblyStoreIndexEntry*>(assembly_store.data_start + header_size);
291291

292-
log_debug (LOG_ASSEMBLY, "Mapped assembly store {}", get_full_store_path ());
292+
log_debug (LOG_ASSEMBLY, "Mapped assembly store {}"sv, get_full_store_path ());
293293
}

src/native/clr/host/fastdev-assemblies.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ auto FastDevAssemblies::open_assembly (std::string_view const& name, int64_t &si
2020

2121
std::string const& override_dir_path = AndroidSystem::get_primary_override_dir ();
2222
if (!Util::dir_exists (override_dir_path)) [[unlikely]] {
23-
log_debug (LOG_ASSEMBLY, "Override directory '{}' does not exist", override_dir_path);
23+
log_debug (LOG_ASSEMBLY, "Override directory '{}' does not exist"sv, override_dir_path);
2424
return nullptr;
2525
}
2626

@@ -31,7 +31,7 @@ auto FastDevAssemblies::open_assembly (std::string_view const& name, int64_t &si
3131
if (override_dir_fd < 0) [[likely]] {
3232
override_dir = opendir (override_dir_path.c_str ());
3333
if (override_dir == nullptr) [[unlikely]] {
34-
log_warn (LOG_ASSEMBLY, "Failed to open override dir '{}'. {}", override_dir_path, strerror (errno));
34+
log_warn (LOG_ASSEMBLY, "Failed to open override dir '{}'. {}"sv, override_dir_path, strerror (errno));
3535
return nullptr;
3636
}
3737
override_dir_fd = dirfd (override_dir);
@@ -40,20 +40,20 @@ auto FastDevAssemblies::open_assembly (std::string_view const& name, int64_t &si
4040

4141
log_debug (
4242
LOG_ASSEMBLY,
43-
"Attempting to load FastDev assembly '{}' from override directory '{}'",
43+
"Attempting to load FastDev assembly '{}' from override directory '{}'"sv,
4444
name,
4545
override_dir_path
4646
);
4747

4848
if (!Util::file_exists (override_dir_fd, name)) {
49-
log_warn (LOG_ASSEMBLY, "FastDev assembly '{}' not found.", name);
49+
log_warn (LOG_ASSEMBLY, "FastDev assembly '{}' not found."sv, name);
5050
return nullptr;
5151
}
52-
log_debug (LOG_ASSEMBLY, "Found FastDev assembly '{}'", name);
52+
log_debug (LOG_ASSEMBLY, "Found FastDev assembly '{}'"sv, name);
5353

5454
auto file_size = Util::get_file_size_at (override_dir_fd, name);
5555
if (!file_size) [[unlikely]] {
56-
log_warn (LOG_ASSEMBLY, "Unable to determine FastDev assembly '{}' file size", name);
56+
log_warn (LOG_ASSEMBLY, "Unable to determine FastDev assembly '{}' file size"sv, name);
5757
return nullptr;
5858
}
5959

@@ -62,7 +62,7 @@ auto FastDevAssemblies::open_assembly (std::string_view const& name, int64_t &si
6262
Helpers::abort_application (
6363
LOG_ASSEMBLY,
6464
std::format (
65-
"FastDev assembly '{}' size exceeds the maximum supported value of {}",
65+
"FastDev assembly '{}' size exceeds the maximum supported value of {}"sv,
6666
name,
6767
MAX_SIZE
6868
)
@@ -74,7 +74,7 @@ auto FastDevAssemblies::open_assembly (std::string_view const& name, int64_t &si
7474
if (asm_fd < 0) {
7575
log_warn (
7676
LOG_ASSEMBLY,
77-
"Failed to open FastDev assembly '{}' for reading. {}",
77+
"Failed to open FastDev assembly '{}' for reading. {}"sv,
7878
name,
7979
strerror (errno)
8080
);
@@ -99,15 +99,15 @@ auto FastDevAssemblies::open_assembly (std::string_view const& name, int64_t &si
9999

100100
log_warn (
101101
LOG_ASSEMBLY,
102-
"Failed to read FastDev assembly '{}' data. {}",
102+
"Failed to read FastDev assembly '{}' data. {}"sv,
103103
name,
104104
strerror (errno)
105105
);
106106

107107
size = 0;
108108
return nullptr;
109109
}
110-
log_debug (LOG_ASSEMBLY, "Read {} bytes of FastDev assembly '{}'", nread, name);
110+
log_debug (LOG_ASSEMBLY, "Read {} bytes of FastDev assembly '{}'"sv, nread, name);
111111

112112
return reinterpret_cast<void*>(buffer);
113113
}

0 commit comments

Comments
 (0)