diff options
author | Eric Wong <e@80x24.org> | 2018-12-06 23:26:24 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-12-12 23:49:38 +0000 |
commit | 16f7018af1f278a9f0cc368e224258860ea4cb8c (patch) | |
tree | 3b4a7149d3f02220023e92a653ce53bdd2c0442b /ext/unicorn_http/extconf.rb | |
parent | 981f561a726bb4307d01e4a09a308edba8d69fe3 (diff) | |
download | unicorn-16f7018af1f278a9f0cc368e224258860ea4cb8c.tar.gz |
String#-@ deduplicates strings starting with Ruby 2.5.0 Hash#[]= deduplicates strings starting in Ruby 2.6.0-rc1 This allows us to save a small amount of memory by sharing objects with other parts of the stack (e.g. Rack).
Diffstat (limited to 'ext/unicorn_http/extconf.rb')
-rw-r--r-- | ext/unicorn_http/extconf.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ext/unicorn_http/extconf.rb b/ext/unicorn_http/extconf.rb index 2fc60fe..d5f81fb 100644 --- a/ext/unicorn_http/extconf.rb +++ b/ext/unicorn_http/extconf.rb @@ -8,4 +8,34 @@ have_func("rb_str_set_len", "ruby.h") or abort 'Ruby 1.9.3+ required' have_func("rb_hash_clear", "ruby.h") # Ruby 2.0+ have_func("gmtime_r", "time.h") +message('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) + $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=1 ' + message("yes\n") + else + $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=0 ' + message("no, needs Ruby 2.5+\n") + end +rescue NoMethodError + $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=0 ' + message("no, String#-@ not available\n") +end + +message('checking if Hash#[]= (rb_hash_aset) dedupes... ') +h = {} +x = {} +r = rand.to_s +h[%W(#{r}).join('')] = :foo +x[%W(#{r}).join('')] = :foo +if x.keys[0].equal?(h.keys[0]) + $CPPFLAGS += ' -DHASH_ASET_DEDUPE=1 ' + message("yes\n") +else + $CPPFLAGS += ' -DHASH_ASET_DEDUPE=0 ' + message("no, needs Ruby 2.6+\n") +end + create_makefile("unicorn_http") |