Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 38e1769

Browse files
committedSep 15, 2023
Use templated constants for Regexp options
1 parent 17dbf4e commit 38e1769

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed
 

‎lib/yarp.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,8 @@ class InterpolatedRegularExpressionNode < Node
590590
# the regular expression.
591591
def options
592592
o = flags & 0b111
593-
o |= Regexp::FIXEDENCODING if flags & 8 != 0 # 'e'
594-
o |= Regexp::FIXEDENCODING if flags & 32 != 0 # 's'
595-
o |= Regexp::FIXEDENCODING if flags & 64 != 0 # 'u'
596-
o |= Regexp::NOENCODING if flags & 16 != 0 # 'n'
593+
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
594+
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
597595
o
598596
end
599597
end
@@ -610,10 +608,8 @@ class RegularExpressionNode < Node
610608
# the regular expression.
611609
def options
612610
o = flags & 0b111
613-
o |= Regexp::FIXEDENCODING if flags & 8 != 0 # 'e'
614-
o |= Regexp::FIXEDENCODING if flags & 32 != 0 # 's'
615-
o |= Regexp::FIXEDENCODING if flags & 64 != 0 # 'u'
616-
o |= Regexp::NOENCODING if flags & 16 != 0 # 'n'
611+
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
612+
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
617613
o
618614
end
619615
end

0 commit comments

Comments
 (0)
Please sign in to comment.