MJIT: Refactor BitField dereference a little
This commit is contained in:
parent
e7443dbbca
commit
cd2da09410
@ -282,12 +282,11 @@ module RubyVM::MJIT
|
|||||||
|
|
||||||
# Dereference
|
# Dereference
|
||||||
def *
|
def *
|
||||||
|
byte = Fiddle::Pointer.new(@addr)[0, Fiddle::SIZEOF_CHAR].unpack('c').first
|
||||||
if @width == 1
|
if @width == 1
|
||||||
byte = Fiddle::Pointer.new(@addr)[0, Fiddle::SIZEOF_CHAR].unpack('c').first
|
|
||||||
bit = (1 & (byte >> @offset))
|
bit = (1 & (byte >> @offset))
|
||||||
bit == 1
|
bit == 1
|
||||||
elsif @width <= 8 && @offset == 0
|
elsif @width <= 8 && @offset == 0
|
||||||
byte = Fiddle::Pointer.new(@addr)[0, Fiddle::SIZEOF_CHAR].unpack('c').first
|
|
||||||
bitmask = @width.times.map { |i| 1 << i }.sum
|
bitmask = @width.times.map { |i| 1 << i }.sum
|
||||||
byte & bitmask
|
byte & bitmask
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user