File tree 1 file changed +3
-20
lines changed
core/src/main/java/org/jruby
1 file changed +3
-20
lines changed Original file line number Diff line number Diff line change @@ -4581,26 +4581,9 @@ public RubyString freezeAndDedupString(RubyString string) {
4581
4581
deduped = string .strDup (this );
4582
4582
deduped .setFrozen (true );
4583
4583
4584
- WeakReference <RubyString > weakref = new WeakReference <>(deduped );
4585
- WeakReference <RubyString > existing ;
4586
- RubyString existingDeduped ;
4587
-
4588
- // Check if someone else beat us to it.
4589
- // NOTE: This still races because Map.compute* API is Java 8+.
4590
- while ((existing = dedupMap .putIfAbsent (deduped , weakref )) != null ) {
4591
-
4592
- existingDeduped = existing .get ();
4593
-
4594
- if (existingDeduped != null ) {
4595
- deduped = existingDeduped ;
4596
- break ;
4597
- }
4598
-
4599
- // keep trying to put it if existing has been evacuated
4600
- }
4601
- }
4602
-
4603
- if (deduped .getEncoding () != string .getEncoding ()) {
4584
+ // NOTE: This still races because Map.put/computeIfAbsent API is Java 8+.
4585
+ dedupMap .put (deduped , new WeakReference <>(deduped ));
4586
+ } else if (deduped .getEncoding () != string .getEncoding ()) {
4604
4587
// if encodings don't match, new string loses; can't dedup
4605
4588
// FIXME: This may never happen, if we are properly considering encoding in RubyString.hashCode
4606
4589
deduped = string .strDup (this );
You can’t perform that action at this time.
0 commit comments