diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2020-09-09 15:24:22 +0200 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2020-09-15 14:49:35 +0200 |
commit | 9bf8aa21b36de3bd90bed85e6c85412426b03d9d (patch) | |
tree | f636f2f8736107a57687d38dfe7ac6f80c47ac92 /ext/json/ext/parser/extconf.rb | |
parent | c5083b238ed2016b968c402990f9de084f415e0d (diff) | |
download | json-9bf8aa21b36de3bd90bed85e6c85412426b03d9d.tar.gz |
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/ext/parser/extconf.rb')
-rw-r--r-- | ext/json/ext/parser/extconf.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/json/ext/parser/extconf.rb b/ext/json/ext/parser/extconf.rb index f7360d4..f832b56 100644 --- a/ext/json/ext/parser/extconf.rb +++ b/ext/json/ext/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' |