Skip to content

Commit f99012b

Browse files
committed
Change: relocated Tags to decrease padding.
64-bit The problematic areas are: SymInfo (6 bytes) → followed by a 2-byte gap Origin (2 bytes) → followed by a 2-byte gap before StringRef Tags (4 bytes) → followed by a 4-byte gap before SmallVector Flags at the end → 7 bytes end padding 32-bit SymInfo → 2-byte gap Origin → 2-byte gap Flags at the end → 3 bytes end padding This patch reduces paddings: 64-bit: 240 -> 232 (-8 Bytes, ~3.3%) 32-bit: 144 -> 140 (-4 Bytes, ~2.8%)
1 parent fad6461 commit f99012b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

clang-tools-extra/clangd/index/Symbol.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ struct Symbol {
5151
SymbolID ID;
5252
/// The symbol information, like symbol kind.
5353
index::SymbolInfo SymInfo = index::SymbolInfo();
54+
/// Where this symbol came from. Usually an index provides a constant value.
55+
SymbolOrigin Origin = SymbolOrigin::Unknown;
5456
/// The unqualified name of the symbol, e.g. "bar" (for ns::bar).
5557
llvm::StringRef Name;
5658
/// The containing namespace. e.g. "" (global), "ns::" (top-level namespace).
@@ -70,8 +72,10 @@ struct Symbol {
7072
/// The number of translation units that reference this symbol from their main
7173
/// file. This number is only meaningful if aggregated in an index.
7274
unsigned References = 0;
73-
/// Where this symbol came from. Usually an index provides a constant value.
74-
SymbolOrigin Origin = SymbolOrigin::Unknown;
75+
/// Symbol tags for LSP protocol (Deprecated, Static, Virtual, Abstract,
76+
/// Final, ReadOnly, Public, Protected, Private, Declaration, Definition).
77+
/// This is a bitmask where each bit represents a SymbolTag.
78+
SymbolTags Tags = 0;
7579
/// A brief description of the symbol that can be appended in the completion
7680
/// candidate list. For example, "(X x, Y y) const" is a function signature.
7781
/// Only set when the symbol is indexed for completion.
@@ -97,11 +101,6 @@ struct Symbol {
97101
/// Only set when the symbol is indexed for completion.
98102
llvm::StringRef Type;
99103

100-
/// Symbol tags for LSP protocol (Deprecated, Static, Virtual, Abstract,
101-
/// Final, ReadOnly, Public, Protected, Private, Declaration, Definition).
102-
/// This is a bitmask where each bit represents a SymbolTag.
103-
SymbolTags Tags = 0;
104-
105104
enum IncludeDirective : uint8_t {
106105
Invalid = 0,
107106
/// `#include "header.h"`

0 commit comments

Comments
 (0)