mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[libSyntax] Improve data structure in RawSyntax
It turns out that the bitpacked Commons struct is actually fairly expensive because the CPU needs to apply bitmasks to fetch the IsToken and Presence flag. We've got padding space available, so we might as well properly align these boolean flags. Also on a source level, replace a couple of bit-restricted unsigned fields by their representing type (e.g. SyntaxKind). Finally, we can pull out the common bits to RawSyntax and have the Bits union only contain the token- or layout-specific fields. This also allows us to initialise these fields in the constructor's initialiser list (instead of in the initialiser body). Lastly, change copyToArenaIfNecessary to work on a char *& and length, which allows us to initialise leading/trailing trivia/token text in the initialiser list and adjust if necessary later.
This commit is contained in:
@@ -32,10 +32,10 @@ class SyntaxParseActions;
|
||||
class SyntaxParsingContext;
|
||||
class SourceLoc;
|
||||
class Token;
|
||||
enum class tok;
|
||||
enum class tok : uint8_t;
|
||||
|
||||
namespace syntax {
|
||||
enum class SyntaxKind;
|
||||
enum class SyntaxKind : uint16_t;
|
||||
}
|
||||
|
||||
class ParsedRawSyntaxRecorder final {
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace swift {
|
||||
|
||||
namespace syntax {
|
||||
class RawSyntax;
|
||||
enum class SyntaxKind;
|
||||
enum class SyntaxKind : uint16_t;
|
||||
}// end of syntax namespace
|
||||
|
||||
/// Different contexts in which BraceItemList are parsed.
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace swift {
|
||||
class ParsedTriviaPiece;
|
||||
class SourceFile;
|
||||
class SourceLoc;
|
||||
enum class tok;
|
||||
enum class tok : uint8_t;
|
||||
|
||||
namespace syntax {
|
||||
class SourceFileSyntax;
|
||||
enum class SyntaxKind;
|
||||
enum class SyntaxKind : uint16_t;
|
||||
}
|
||||
|
||||
typedef const void *OpaqueSyntaxNode;
|
||||
|
||||
@@ -27,12 +27,12 @@ class ParsedSyntax;
|
||||
class ParsedTokenSyntax;
|
||||
struct ParsedTrivia;
|
||||
class SourceFile;
|
||||
enum class tok;
|
||||
enum class tok : uint8_t;
|
||||
class Token;
|
||||
class DiagnosticEngine;
|
||||
|
||||
namespace syntax {
|
||||
enum class SyntaxKind;
|
||||
enum class SyntaxKind : uint16_t;
|
||||
}
|
||||
|
||||
enum class SyntaxContextKind {
|
||||
|
||||
Reference in New Issue
Block a user