Commit 595586a
committed
i18n: use translation table for source strings; shrink .exe
The QLJS_TRANSLATABLE macro creates a translatable_message object
containing a const char* and a uint16_t. The uint16_t is an index into a
translation table, and the const char* is a pointer to the untranslated
C string. This has some problems:
* Each translatable_message consumes 10 bytes. These bytes add up
quickly in the diagnostics table.
* Each translatable_message requires a relocation entry (assuming
position-independent code generation), so it actually consumes more
than 10 bytes.
* In the future, I want to compress the translation string table [1].
This compression would not affect untranslated strings.
Change the QLJS_TRANSLATABLE macro to not store a const char*. Instead,
put the untranslated string into the translation table.
This commit reduces the size of the CLI by a dozen or two kilobytes:
file | before | after | change
----------------------------------------------+---------+---------+--------
2.4.0-1_amd64.deb::quick-lint-js | 787568 | 771184 | -2%
manual/windows-arm.zip::quick-lint-js.exe | 863744 | 861696 | 0%
manual/windows-arm64.zip::quick-lint-js.exe | 1017856 | 1012224 | -1%
manual/windows-x86.zip::quick-lint-js.exe | 1165838 | 1163790 | 0%
manual/windows.zip::quick-lint-js.exe | 1185280 | 1177088 | -1%
npm/2.4.0.tgz::darwin-arm64/quick-lint-js | 655376 | 654528 | 0%
npm/2.4.0.tgz::darwin-x64/quick-lint-js | 1244384 | 1221152 | -2%
npm/2.4.0.tgz::linux-arm/quick-lint-js | 496944 | 492848 | -1%
npm/2.4.0.tgz::linux-arm64/quick-lint-js | 771000 | 750520 | -3%
npm/2.4.0.tgz::linux-x64/quick-lint-js | 831528 | 823336 | -1%
npm/2.4.0.tgz::win32-arm64/quick-lint-js.exe | 1017856 | 1012224 | -1%
npm/2.4.0.tgz::win32-ia32/quick-lint-js.exe | 1165838 | 1163790 | 0%
npm/2.4.0.tgz::win32-x64/quick-lint-js.exe | 1185280 | 1177088 | -1%
vscode/2.4.0.vsix::darwin-arm64.node | 507144 | 539320 | 6%
vscode/2.4.0.vsix::darwin-x64.node | 769008 | 805024 | 5%
vscode/2.4.0.vsix::linux-arm.node | 436068 | 431972 | -1%
vscode/2.4.0.vsix::linux-arm64.node | 685840 | 669456 | -2%
vscode/2.4.0.vsix::linux-x64.node | 747760 | 735472 | -2%
vscode/2.4.0.vsix::win32-arm.node | 514560 | 551936 | 7%
vscode/2.4.0.vsix::win32-arm64.node | 642560 | 677376 | 5%
vscode/2.4.0.vsix::win32-ia32.node | 921102 | 919054 | 0%
vscode/2.4.0.vsix::win32-x64.node | 928768 | 923136 | -1%
website/website.zip::vscode.wasm | 290283 | 328057 | 13%
The size of quick-lint-js.wasm and the Visual Studio Code .node files
increased because the translation table is now included in the binary.
Previously the translation table was dead-stripped because localization
is disabled for WASM and for VS Code. We want the localization table in
the .wasm file [2] and VS Code extension [3] anyway, so the size
increase is tolerable.
[1] #687
[2] #433
[3] #5291 parent dcf063e commit 595586a
File tree
19 files changed
+1992
-577
lines changed- benchmark
- po
- src
- quick-lint-js
- test
- quick-lint-js
- tools
19 files changed
+1992
-577
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
16 | 17 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
33 | | - | |
| 42 | + | |
| 43 | + | |
34 | 44 | | |
35 | | - | |
36 | | - | |
| 45 | + | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
40 | | - | |
41 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
42 | 53 | | |
43 | 54 | | |
44 | 55 | | |
45 | 56 | | |
46 | 57 | | |
47 | 58 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
52 | 68 | | |
53 | 69 | | |
54 | 70 | | |
55 | 71 | | |
56 | | - | |
| 72 | + | |
| 73 | + | |
57 | 74 | | |
58 | | - | |
59 | | - | |
| 75 | + | |
| 76 | + | |
60 | 77 | | |
61 | 78 | | |
62 | 79 | | |
63 | | - | |
64 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
65 | 83 | | |
66 | 84 | | |
67 | 85 | | |
| |||
87 | 105 | | |
88 | 106 | | |
89 | 107 | | |
90 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
91 | 111 | | |
92 | 112 | | |
93 | 113 | | |
| |||
96 | 116 | | |
97 | 117 | | |
98 | 118 | | |
99 | | - | |
| 119 | + | |
100 | 120 | | |
101 | 121 | | |
102 | 122 | | |
| |||
110 | 130 | | |
111 | 131 | | |
112 | 132 | | |
113 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
114 | 136 | | |
115 | 137 | | |
116 | 138 | | |
| |||
119 | 141 | | |
120 | 142 | | |
121 | 143 | | |
122 | | - | |
| 144 | + | |
123 | 145 | | |
124 | 146 | | |
125 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
33 | 49 | | |
34 | 50 | | |
35 | 51 | | |
| |||
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| |||
1068 | 1076 | | |
1069 | 1077 | | |
1070 | 1078 | | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1071 | 1120 | | |
1072 | 1121 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
33 | 49 | | |
34 | 50 | | |
35 | 51 | | |
| |||
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| |||
1047 | 1055 | | |
1048 | 1056 | | |
1049 | 1057 | | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1050 | 1099 | | |
1051 | 1100 | | |
0 commit comments