Skip to content

Commit cfe6e0c

Browse files
authored
Merge pull request #13640 from davezarzycki/nfc_repack_two_pattern_bits
2 parents 3e3ca91 + 296d1b8 commit cfe6e0c

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

include/swift/AST/Pattern.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ class alignas(8) Pattern {
6767
IsPropagatedType : 1
6868
);
6969

70+
SWIFT_INLINE_BITFIELD(BoolPattern, Pattern, 1,
71+
Value : 1
72+
);
73+
74+
SWIFT_INLINE_BITFIELD(VarPattern, Pattern, 1,
75+
/// True if this is a let pattern, false if a var pattern.
76+
IsLet : 1
77+
);
78+
7079
} Bits;
7180

7281
Pattern(PatternKind kind) {
@@ -581,15 +590,15 @@ class EnumElementPattern : public Pattern {
581590
/// matched against the associated value for the case.
582591
class BoolPattern : public Pattern {
583592
SourceLoc NameLoc;
584-
bool Value;
585593

586594
public:
587595
BoolPattern(SourceLoc NameLoc, bool Value)
588-
: Pattern(PatternKind::Bool), NameLoc(NameLoc), Value(Value) {
596+
: Pattern(PatternKind::Bool), NameLoc(NameLoc) {
597+
Bits.BoolPattern.Value = Value;
589598
}
590599

591-
bool getValue() const { return Value; }
592-
void setValue(bool v) { Value = v; }
600+
bool getValue() const { return Bits.BoolPattern.Value; }
601+
void setValue(bool v) { Bits.BoolPattern.Value = v; }
593602

594603
SourceLoc getNameLoc() const { return NameLoc; }
595604
SourceLoc getLoc() const { return NameLoc; }
@@ -703,17 +712,17 @@ class ExprPattern : public Pattern {
703712
/// parsed as expressions referencing existing entities.
704713
class VarPattern : public Pattern {
705714
SourceLoc VarLoc;
706-
bool IsLet; // True if this is a let pattern, false if a var pattern.
707715
Pattern *SubPattern;
708716
public:
709717
VarPattern(SourceLoc loc, bool isLet, Pattern *sub,
710718
Optional<bool> implicit = None)
711-
: Pattern(PatternKind::Var), VarLoc(loc), IsLet(isLet), SubPattern(sub) {
719+
: Pattern(PatternKind::Var), VarLoc(loc), SubPattern(sub) {
720+
Bits.VarPattern.IsLet = isLet;
712721
if (implicit.hasValue() ? *implicit : !loc.isValid())
713722
setImplicit();
714723
}
715724

716-
bool isLet() const { return IsLet; }
725+
bool isLet() const { return Bits.VarPattern.IsLet; }
717726

718727
SourceLoc getLoc() const { return VarLoc; }
719728
SourceRange getSourceRange() const {

0 commit comments

Comments
 (0)