diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2020-09-09 15:24:22 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-10-20 21:40:25 +0900 |
commit | 520e0916af0fe53a5ca57269a2bae50cc60e4241 (patch) | |
tree | 0e5b9d615852b0557cc6cd95ce851d59df9d6121 /ext/json/parser/extconf.rb | |
parent | f6680c9ad1b334f094144d788887cd33f7043f41 (diff) |
Implement a freeze: parser option
If set to true all parsed objects will be
immediately frozen, and strings will be
deduplicated if the Ruby implementation
allows it.
Diffstat (limited to 'ext/json/parser/extconf.rb')
-rw-r--r-- | ext/json/parser/extconf.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/json/parser/extconf.rb b/ext/json/parser/extconf.rb index f7360d46b2..f832b56a61 100644 --- a/ext/json/parser/extconf.rb +++ b/ext/json/parser/extconf.rb @@ -3,4 +3,29 @@ require 'mkmf' 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' |