summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-26 05:32:47 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-26 05:32:47 +0000
commit1e83e15ab55c427fe89c7497d7d813b5a884401f (patch)
tree4223d582bbddf1a11b8f733fd3de53b4d7508d83 /hash.c
parent7cc758f7a84f8207e8e589d3cb8a8cbc813cfd88 (diff)
hash.c: aset deduplicates un-tainted string
We revisit [Bug #9188] since st.c is much improved since then, and benchmarks against so_k_nucleotide seem to indicate little or no performance change compared to before. [ruby-core:89555] [Feature #15251] From: Anmol Chopra <chopraanmol1@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index fc38f2f..3f278e0 100644
--- a/hash.c
+++ b/hash.c
@@ -1587,11 +1587,15 @@ VALUE
rb_hash_key_str(VALUE key)
{
VALUE k;
+ int not_tainted = !RB_OBJ_TAINTED(key);
- if (!RB_OBJ_TAINTED(key) &&
+ if (not_tainted &&
(k = fstring_existing_str(key)) != Qnil) {
return k;
}
+ else if(not_tainted) {
+ return rb_fstring(key);
+ }
else {
return rb_str_new_frozen(key);
}