Skip to content

Commit

Permalink
Merge pull request #447 from Shopify/global-freeze-option
Browse files Browse the repository at this point in the history
Implement a freeze: parser option
  • Loading branch information
hsbt committed Oct 20, 2020
2 parents 01e4823 + 9bf8aa2 commit d76e5fc
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 120 deletions.
25 changes: 25 additions & 0 deletions ext/json/ext/parser/extconf.rb
Expand Up @@ -3,4 +3,29 @@

have_func("rb_enc_raise", "ruby.h")

# checking if String#-@ (str_uminus) dedupes... '
begin
a = -(%w(t e s t).join)
b = -(%w(t e s t).join)
if a.equal?(b)
$CFLAGS << ' -DSTR_UMINUS_DEDUPE=1 '
else
$CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
end
rescue NoMethodError
$CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
end

# checking if String#-@ (str_uminus) directly interns frozen strings... '
begin
s = rand.to_s.freeze
if (-s).equal?(s) && (-s.dup).equal?(s)
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 '
else
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
end
rescue NoMethodError
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
end

create_makefile 'json/ext/parser'

0 comments on commit d76e5fc

Please sign in to comment.