mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
1cb77f2304
- The method was renamed from `get` to `get_value` - Comparing to `String#unpack` isn't quite equivalent, `unpack1` is closer. - Use frozen_string_literal to avoid allocating a format string every time. - Use `N` format which is equivalent to `:U32` (`uint_32_t` big-endian). - Disable experimental warnings to not mess up the output.
10 lines
254 B
YAML
10 lines
254 B
YAML
prelude: |
|
|
# frozen_string_literal: true
|
|
Warning[:experimental] = false
|
|
buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
|
|
string = "\0" * 32
|
|
benchmark:
|
|
buffer.get_value: |
|
|
buffer.get_value(:U32, 0)
|
|
string.unpack1: |
|
|
string.unpack1("N")
|