Skip to content

Commit 32319e3

Browse files
bewRX14
authored andcommittedDec 3, 2017
Refactor missing unsafe_as (#5341)
1 parent b747f5f commit 32319e3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed
 

‎src/crystal/system/unix/getrandom.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module Crystal::System::Random
4242
if @@getrandom_available
4343
buf = uninitialized UInt8[1]
4444
getrandom(buf.to_slice)
45-
buf.to_unsafe.as(UInt8*).value
45+
buf.unsafe_as(UInt8)
4646
elsif urandom = @@urandom
4747
urandom.read_byte.not_nil!
4848
else

‎src/io/byte_format.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ module IO::ByteFormat
149149
buffer = uninitialized UInt8[{{bytesize}}]
150150
io.read_fully(buffer.to_slice)
151151
buffer.reverse! unless SystemEndian == self
152-
buffer.to_unsafe.as(Pointer({{type.id}})).value
152+
buffer.unsafe_as({{type.id}})
153153
end
154154

155155
def self.decode(type : {{type.id}}.class, bytes : Bytes)
156156
buffer = uninitialized UInt8[{{bytesize}}]
157157
bytes.to_slice[0, {{bytesize}}].copy_to(buffer.to_slice)
158158
buffer.reverse! unless SystemEndian == self
159-
buffer.to_unsafe.as(Pointer({{type.id}})).value
159+
buffer.unsafe_as({{type.id}})
160160
end
161161
{% end %}
162162
end

‎src/random/secure.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module Random::Secure
4545
end
4646
else
4747
random_bytes(buf.to_slice)
48-
buf.to_unsafe.as({{type}}*).value
48+
buf.unsafe_as({{type}})
4949
end
5050
end
5151
{% end %}

0 commit comments

Comments
 (0)
Please sign in to comment.