Skip to content

Commit 82e5e31

Browse files
zslajchrtansalond
authored andcommitted
CharSXPWrapper caching fixed
(cherry picked from commit 8dec54a)
1 parent 8a2962e commit 82e5e31

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/CharSXPWrapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
2828
import com.oracle.truffle.r.runtime.RRuntime;
29+
import com.oracle.truffle.r.runtime.Utils;
30+
2931
import java.lang.ref.WeakReference;
3032
import java.util.Map;
3133
import java.util.WeakHashMap;
@@ -49,7 +51,7 @@ public final class CharSXPWrapper extends RObject implements RTruffleObject {
4951
private static final Map<CharSXPWrapper, WeakReference<CharSXPWrapper>> instances = new WeakHashMap<>(2048);
5052

5153
private CharSXPWrapper(String contents) {
52-
this.contents = contents;
54+
this.contents = Utils.intern(contents);
5355
}
5456

5557
@TruffleBoundary
@@ -61,7 +63,7 @@ public String getContents() {
6163
return RRuntime.STRING_NA;
6264
}
6365
// WARNING:
64-
// we keep and use the contens value even in cases when contets got allocated and could be
66+
// we keep and use the contents value even in cases when contents got allocated and could be
6567
// accessed via NativeDataAccess.getData():
6668
// - when used with RSymbol the String has to be interned - NDA.getData() will create a new
6769
// instance if already allocated

0 commit comments

Comments
 (0)