Skip to content

Commit 436b811

Browse files
committed
Refactor: shrink diagnostic table with bitfields
Use bitfields to save two bytes from each diagnostic_info. This commit should not change behavior.
1 parent 9783b88 commit 436b811

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/diagnostic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ std::array<char, 5> error_code_to_string(std::uint16_t error_code) noexcept {
6161
template <class Error>
6262
class diagnostic_info_builder {
6363
public:
64+
QLJS_WARNING_PUSH
65+
QLJS_WARNING_IGNORE_GCC("-Wconversion")
6466
constexpr explicit diagnostic_info_builder(const char* code_string,
6567
diagnostic_severity sev) {
6668
this->info_.severity = sev;
6769
this->info_.code = parse_code_string(code_string);
6870
}
71+
QLJS_WARNING_POP
6972

7073
// Each of Args must be a diagnostic_message_arg_info.
7174
template <class... Args>

src/quick-lint-js/diagnostic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ struct diagnostic_message_info {
8181
struct diagnostic_info {
8282
std::array<char, 5> code_string() const noexcept;
8383

84-
std::uint16_t code;
85-
diagnostic_severity severity QLJS_WORK_AROUND_GCC_BUG_105191;
84+
std::uint16_t code : 14;
85+
diagnostic_severity severity : 2 QLJS_WORK_AROUND_GCC_BUG_105191;
8686
// If we support more than two infos (i.e. more than one note), the VS Code
8787
// plugin needs to be updated. See NOTE(multiple notes).
8888
diagnostic_message_info messages[2];

0 commit comments

Comments
 (0)