summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-26 05:33:28 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-26 05:33:28 +0000
commit667c0a3a8caeaa96378f778ee2fbef1b51c3cd13 (patch)
tree1de2fe805226a52bd752a09e18bd8139912e7787
parenta52be8fb8fc61d7e0aa4cba452c30497fd495590 (diff)
Signal.list deduplicates keys
This allows us to reuse string objects used in symbols as well as any string representations of signal names in source code. * signal.c (sig_list): use fstring for hash key * test/ruby/test_signal.rb (test_signal_list_dedupe_keys): added git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--signal.c2
-rw-r--r--test/ruby/test_signal.rb6
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 71aed6e..60b51de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jan 26 14:26:46 2016 Eric Wong <e@80x24.org>
+
+ * signal.c (sig_list): use fstring for hash key
+ * test/ruby/test_signal.rb (test_signal_list_dedupe_keys): added
+
Tue Jan 26 13:08:34 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* signal.c (rb_f_kill): should immediately deliver reserved
diff --git a/signal.c b/signal.c
index cac90db..492e682 100644
--- a/signal.c
+++ b/signal.c
@@ -1347,7 +1347,7 @@ sig_list(void)
const struct signals *sigs;
for (sigs = siglist; sigs->signm; sigs++) {
- rb_hash_aset(h, rb_str_new2(sigs->signm), INT2FIX(sigs->signo));
+ rb_hash_aset(h, rb_fstring_cstr(sigs->signm), INT2FIX(sigs->signo));
}
return h;
}
diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb
index 13d5201..c48a4ad 100644
--- a/test/ruby/test_signal.rb
+++ b/test/ruby/test_signal.rb
@@ -301,4 +301,10 @@ EOS
assert_ruby_status(['-e', 'Process.kill(:CONT, $$)'])
end
end if Process.respond_to?(:kill)
+
+ def test_signal_list_dedupe_keys
+ a = Signal.list.keys.map(&:object_id).sort
+ b = Signal.list.keys.map(&:object_id).sort
+ assert_equal a, b
+ end
end