Skip to content

Commit

Permalink
Replace #to_i32 calls with #to_i
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Zhigalkin committed Jan 25, 2023
1 parent d462c0c commit 078f476
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/pluto/operation/horizontal_blur.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ module Pluto::Operation::HorizontalBlur
l_index : Int32 = c_index
r_index : Int32 = c_index + value

f_value : Int32 = channel.unsafe_fetch(c_index).to_i32
l_value : Int32 = channel.unsafe_fetch(c_index + @width - 1).to_i32
f_value : Int32 = channel.unsafe_fetch(c_index).to_i
l_value : Int32 = channel.unsafe_fetch(c_index + @width - 1).to_i
c_value : Int32 = (value + 1) * f_value

(0..value - 1).each do
c_value += channel.unsafe_fetch(c_index)
end

(0..value).each do
c_value += channel.unsafe_fetch(r_index).to_i32 - f_value
c_value += channel.unsafe_fetch(r_index).to_i - f_value
buffer.unsafe_put(c_index, (c_value * multiplier).to_u8)

r_index += 1
c_index += 1
end

(value + 1..@width - value - 1).each do
c_value += (channel.unsafe_fetch(r_index).to_i32 - channel.unsafe_fetch(l_index).to_i32)
c_value += (channel.unsafe_fetch(r_index).to_i - channel.unsafe_fetch(l_index).to_i)
buffer.unsafe_put(c_index, (c_value * multiplier).to_u8)

r_index += 1
Expand All @@ -41,7 +41,7 @@ module Pluto::Operation::HorizontalBlur
end

(@width - value..@width - 1).each do
c_value += l_value - channel.unsafe_fetch(l_index).to_i32
c_value += l_value - channel.unsafe_fetch(l_index).to_i
buffer.unsafe_put(c_index, (c_value * multiplier).to_u8)

l_index += 1
Expand Down
10 changes: 5 additions & 5 deletions src/pluto/operation/vertical_blur.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ module Pluto::Operation::VerticalBlur
l_index : Int32 = c_index
r_index : Int32 = c_index + value * @width

f_value : Int32 = channel.unsafe_fetch(c_index).to_i32
l_value : Int32 = channel.unsafe_fetch(c_index + @width * (@height - 1)).to_i32
f_value : Int32 = channel.unsafe_fetch(c_index).to_i
l_value : Int32 = channel.unsafe_fetch(c_index + @width * (@height - 1)).to_i
c_value : Int32 = (value + 1) * f_value

(0..value - 1).each do
c_value += channel.unsafe_fetch(c_index)
end

(0..value).each do
c_value += channel.unsafe_fetch(r_index).to_i32 - f_value
c_value += channel.unsafe_fetch(r_index).to_i - f_value
buffer.unsafe_put(c_index, (c_value * multiplier).to_u8)

r_index += @width
c_index += @width
end

(value + 1..@height - value - 1).each do
c_value += channel.unsafe_fetch(r_index).to_i32 - channel.unsafe_fetch(l_index).to_i32
c_value += channel.unsafe_fetch(r_index).to_i - channel.unsafe_fetch(l_index).to_i
buffer.unsafe_put(c_index, (c_value * multiplier).to_u8)

l_index += @width
Expand All @@ -41,7 +41,7 @@ module Pluto::Operation::VerticalBlur
end

(@height - value..@height - 1).each do
c_value += l_value - channel.unsafe_fetch(l_index).to_i32
c_value += l_value - channel.unsafe_fetch(l_index).to_i
buffer.unsafe_put(c_index, (c_value * multiplier).to_u8)

l_index += @width
Expand Down

0 comments on commit 078f476

Please sign in to comment.