Skip to content

Commit 496af80

Browse files
committed
Small refactoring of PythonEngineOptions.
1 parent 0b6ee3f commit 496af80

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ List<WeakReference<Thread>> getOwners() {
223223
// compat
224224
private final ThreadLocal<ArrayDeque<String>> currentImport = new ThreadLocal<>();
225225

226-
private PythonEngineOptions engineOptions;
226+
@CompilationFinal private PythonEngineOptions engineOptions;
227227

228228
public PythonContext(PythonLanguage language, TruffleLanguage.Env env, PythonCore core) {
229229
this.language = language;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonEngineOptions.java

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,20 @@
4848
public class PythonEngineOptions {
4949
@CompilationFinal private OptionValues optionValues;
5050

51-
@CompilationFinal private int builtinsInliningMaxCallerSize;
52-
@CompilationFinal private boolean catchAllExceptions;
53-
@CompilationFinal private boolean emulatedJython;
54-
@CompilationFinal private boolean exposeInternalSources;
55-
@CompilationFinal private boolean withThread;
51+
private final int builtinsInliningMaxCallerSize;
52+
private final boolean catchAllExceptions;
53+
private final boolean emulatedJython;
54+
private final boolean exposeInternalSources;
55+
private final boolean withThread;
5656

5757
PythonEngineOptions(OptionValues optionValues) {
58+
CompilerAsserts.neverPartOfCompilation();
5859
this.optionValues = optionValues;
59-
setOptionValues(optionValues);
60+
this.builtinsInliningMaxCallerSize = readIntegerOption(PythonOptions.BuiltinsInliningMaxCallerSize);
61+
this.catchAllExceptions = readBooleanOption(PythonOptions.CatchAllExceptions);
62+
this.emulatedJython = readBooleanOption(PythonOptions.EmulateJython);
63+
this.exposeInternalSources = readBooleanOption(PythonOptions.ExposeInternalSources);
64+
this.withThread = readBooleanOption(PythonOptions.WithThread);
6065
}
6166

6267
public static PythonEngineOptions fromOptionValues(OptionValues optionValues) {
@@ -71,20 +76,6 @@ private int readIntegerOption(OptionKey<Integer> key) {
7176
return key.getValue(optionValues);
7277
}
7378

74-
public void setOptionValues(OptionValues newOptions) {
75-
CompilerAsserts.neverPartOfCompilation();
76-
optionValues = newOptions;
77-
cacheOptions();
78-
}
79-
80-
private void cacheOptions() {
81-
this.builtinsInliningMaxCallerSize = readIntegerOption(PythonOptions.BuiltinsInliningMaxCallerSize);
82-
this.catchAllExceptions = readBooleanOption(PythonOptions.CatchAllExceptions);
83-
this.emulatedJython = readBooleanOption(PythonOptions.EmulateJython);
84-
this.exposeInternalSources = readBooleanOption(PythonOptions.ExposeInternalSources);
85-
this.withThread = readBooleanOption(PythonOptions.WithThread);
86-
}
87-
8879
public boolean areInternalSourcesExposed() {
8980
return this.exposeInternalSources;
9081
}

0 commit comments

Comments
 (0)