Skip to content

Commit 6ee8d87

Browse files
committed
Do not call #require if the constant is already published
1 parent 88924ec commit 6ee8d87

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/org/truffleruby/language/constants/GetConstantNode.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ protected Object autoloadConstant(
126126
// Mark the autoload constant as loading already here and not in RequireNode so that recursive lookups act as "being loaded"
127127
autoloadConstantStart(getContext(), constant, this);
128128
try {
129-
try {
130-
callRequireNode.call(coreLibrary().mainObject, "require", feature);
131-
} finally {
132-
if (autoloadConstant.shouldPublish()) {
133-
autoloadConstant.publish(getContext(), constant);
129+
if (!constant.getAutoloadConstant().isPublished()) {
130+
try {
131+
callRequireNode.call(coreLibrary().mainObject, "require", feature);
132+
} finally {
133+
if (autoloadConstant.shouldPublish()) {
134+
autoloadConstant.publish(getContext(), constant);
135+
}
134136
}
135137
}
136138

0 commit comments

Comments
 (0)