Skip to content

Commit ce8f17e

Browse files
committed
use constant for import all in AbstractImportNode.importModule()
1 parent 3fcf23f commit ce8f17e

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextImportBuiltins.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
*/
4141
package com.oracle.graal.python.builtins.modules.cext;
4242

43+
import static com.oracle.graal.python.nodes.statement.AbstractImportNode.IMPORT_ALL;
44+
4345
import com.oracle.graal.python.builtins.Builtin;
4446
import java.util.List;
4547
import com.oracle.graal.python.builtins.CoreFunctions;
@@ -80,7 +82,7 @@ public Object imp(String name,
8082
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
8183
@Cached GetNativeNullNode getNativeNull) {
8284
try {
83-
return AbstractImportNode.importModule(name, new String[]{"*"});
85+
return AbstractImportNode.importModule(name, IMPORT_ALL);
8486
} catch (PException e) {
8587
transformExceptionToNativeNode.execute(e);
8688
return getNativeNull.execute();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787

8888
public abstract class AbstractImportNode extends StatementNode {
8989

90+
@CompilationFinal(dimensions = 1) public static final String[] IMPORT_ALL = new String[]{"*"};
91+
9092
@Child ImportName importNameNode;
9193

9294
public AbstractImportNode() {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/ImportStarNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public ImportStarNode(String moduleName, int level) {
116116

117117
@Override
118118
public void executeVoid(VirtualFrame frame) {
119-
Object importedModule = importModule(frame, moduleName, PArguments.getGlobals(frame), new String[]{"*"}, level);
119+
Object importedModule = importModule(frame, moduleName, PArguments.getGlobals(frame), IMPORT_ALL, level);
120120
PythonObject locals = fastGetCustomLocalsOrGlobals(frame, havePyFrame, haveCustomLocals);
121121

122122
if (javaImport.profile(emulateJython() && getContext().getEnv().isHostObject(importedModule))) {

0 commit comments

Comments
 (0)