Skip to content

Commit

Permalink
Merge pull request #285 from Shopify/more-dead-code
Browse files Browse the repository at this point in the history
Remove some more rubinius code
  • Loading branch information
byroot committed Jul 1, 2022
2 parents 9e6ce3d + 96e4ce7 commit 1998a32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
18 changes: 5 additions & 13 deletions ext/msgpack/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

have_header("ruby/st.h")
have_header("st.h")
have_func("rb_enc_interned_str", "ruby.h")
have_func("rb_hash_new_capa", "ruby.h")
have_func("rb_enc_interned_str", "ruby.h") # Ruby 3.0+
have_func("rb_hash_new_capa", "ruby.h") # Ruby 3.2+

unless RUBY_PLATFORM.include? 'mswin'
$CFLAGS << %[ -I.. -Wall -O3 -g -std=gnu99]
Expand All @@ -13,19 +13,12 @@
#$CFLAGS << %[ -DDISABLE_BUFFER_READ_REFERENCE_OPTIMIZE]
#$CFLAGS << %[ -DDISABLE_BUFFER_READ_TO_S_OPTIMIZE]

if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
# msgpack-ruby doesn't modify data came from RSTRING_PTR(str)
$CFLAGS << %[ -DRSTRING_NOT_MODIFIED]
# Rubinius C extensions don't grab GVL while rmem is not thread safe
$CFLAGS << %[ -DDISABLE_RMEM]
end

if RUBY_VERSION.start_with?('3.0.')
# https://bugs.ruby-lang.org/issues/18772
$CFLAGS << ' -DRB_ENC_INTERNED_STR_NULL_CHECK=1 '
end

# checking if Hash#[]= (rb_hash_aset) dedupes string keys
# checking if Hash#[]= (rb_hash_aset) dedupes string keys (Ruby 2.6+)
h = {}
x = {}
r = rand.to_s
Expand All @@ -38,7 +31,7 @@
end


# checking if String#-@ (str_uminus) dedupes... '
# checking if String#-@ (str_uminus) dedupes... ' (Ruby 2.5+)
begin
a = -(%w(t e s t).join)
b = -(%w(t e s t).join)
Expand All @@ -51,7 +44,7 @@
$CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
end

# checking if String#-@ (str_uminus) directly interns frozen strings... '
# checking if String#-@ (str_uminus) directly interns frozen strings... ' (Ruby 3.0+)
begin
s = rand.to_s.freeze
if (-s).equal?(s) && (-s.dup).equal?(s)
Expand All @@ -68,4 +61,3 @@
end

create_makefile('msgpack/msgpack')

8 changes: 1 addition & 7 deletions ext/msgpack/packer.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,7 @@ static inline bool msgpack_packer_is_utf8_compat_string(VALUE v, int encindex)
{
return encindex == msgpack_rb_encindex_utf8
|| encindex == msgpack_rb_encindex_usascii
#ifdef ENC_CODERANGE_ASCIIONLY
/* Because ENC_CODERANGE_ASCIIONLY does not scan string, it may return ENC_CODERANGE_UNKNOWN unlike */
/* rb_enc_str_asciionly_p. It is always faster than rb_str_encode if it is available. */
/* Very old Rubinius (< v1.3.1) doesn't have ENC_CODERANGE_ASCIIONLY. */
|| (rb_enc_asciicompat(rb_enc_from_index(encindex)) && ENC_CODERANGE_ASCIIONLY(v))
#endif
;
|| (rb_enc_asciicompat(rb_enc_from_index(encindex)) && ENC_CODERANGE_ASCIIONLY(v));
}

static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE v)
Expand Down

0 comments on commit 1998a32

Please sign in to comment.