mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
Reduce size of MR_win32_error_name.
All the strings returned by MR_win32_error_name include a common prefix
"ERROR_". Since there are many (1749) such strings, we can reduce the
size of the data by about 10 KB by returning only the part following the
prefix.
tools/generate_windows_error_name:
runtime/mercury_windows_error_name.c:
Make MR_win32_error_name return strings without the "ERROR_" prefix.
library/io.m:
Update caller system_error_win32_error_name to add the "ERROR_"
prefix.
This commit is contained in:
15
library/io.m
15
library/io.m
@@ -4979,9 +4979,18 @@ system_error_errno_name(_, _) :-
|
||||
[will_not_call_mercury, promise_pure, thread_safe, may_not_export_body],
|
||||
"
|
||||
#ifdef MR_WIN32
|
||||
const char *str = MR_win32_error_name(ErrorCode);
|
||||
if (str != NULL) {
|
||||
Name = (MR_String) str;
|
||||
const char *suffix = MR_win32_error_name(ErrorCode);
|
||||
if (suffix != NULL) {
|
||||
const char prefix[6] = ""ERROR_"";
|
||||
size_t prefix_len;
|
||||
size_t suffix_len;
|
||||
|
||||
prefix_len = sizeof(prefix);
|
||||
suffix_len = strlen(suffix);
|
||||
MR_allocate_aligned_string_msg(Name, prefix_len + suffix_len,
|
||||
MR_ALLOC_ID);
|
||||
MR_memcpy(Name, prefix, prefix_len);
|
||||
MR_memcpy(Name + prefix_len, suffix, suffix_len + 1); // include NUL
|
||||
} else {
|
||||
Name = MR_make_string(MR_ALLOC_ID, ""System error 0x%X"", ErrorCode);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1787,7 +1787,8 @@ MR_win32_error_name(DWORD errcode)
|
||||
EOF
|
||||
|
||||
for name in $names ; do
|
||||
echo " case $name: return \"$name\";"
|
||||
shortname=${name#ERROR_}
|
||||
echo " case $name: return \"$shortname\";"
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Reference in New Issue
Block a user