Skip to content

Commit ee2ee7f

Browse files
committedJan 22, 2018
Additional tweaks to remove Java 8 APIs for #4970.
1 parent 7651881 commit ee2ee7f

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed
 

‎core/src/main/java/org/jruby/Ruby.java

+3-20
Original file line numberDiff line numberDiff line change
@@ -4581,26 +4581,9 @@ public RubyString freezeAndDedupString(RubyString string) {
45814581
deduped = string.strDup(this);
45824582
deduped.setFrozen(true);
45834583

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()) {
46044587
// if encodings don't match, new string loses; can't dedup
46054588
// FIXME: This may never happen, if we are properly considering encoding in RubyString.hashCode
46064589
deduped = string.strDup(this);

0 commit comments

Comments
 (0)
Please sign in to comment.