Skip to content

Commit 8bff015

Browse files
committed
give same id for same strings to simulate interning
1 parent a514226 commit 8bff015

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,10 +974,15 @@ long doString(String s) {
974974
} else if (s.length() == 1) {
975975
return (~s.codePointAt(0) << IDTAG_SHIFT) | IDTAG_SPECIAL;
976976
} else {
977-
return doGeneric(s);
977+
return strHash(s);
978978
}
979979
}
980980

981+
@TruffleBoundary
982+
private static int strHash(String s) {
983+
return s.hashCode();
984+
}
985+
981986
@Specialization
982987
long doPString(PString s,
983988
@Shared("isBuiltin") @Cached IsBuiltinClassProfile isBuiltin,

0 commit comments

Comments
 (0)