40
40
*/
41
41
package com .oracle .graal .python .builtins .objects .str ;
42
42
43
+ import org .graalvm .nativeimage .ImageInfo ;
44
+
43
45
import com .oracle .graal .python .nodes .PGuards ;
44
46
import com .oracle .graal .python .runtime .PythonOptions ;
45
47
import com .oracle .truffle .api .CompilerAsserts ;
@@ -51,20 +53,13 @@ public class LazyString implements CharSequence {
51
53
protected static final int MinLazyStringLength ;
52
54
protected static final boolean UseLazyStrings ;
53
55
static {
54
- boolean useLazyStrings ;
55
- int minLazyStringLength ;
56
- try {
57
- useLazyStrings = PythonOptions .useLazyString ();
58
- minLazyStringLength = PythonOptions .getMinLazyStringLength ();
59
- } catch (AssertionError e ) {
60
- // This can happen e.g. when we build a native image without
61
- // a pre-initialized Python context
62
- assert e .getMessage ().equals ("No current context available" );
63
- useLazyStrings = PythonOptions .LazyStrings .getDefaultValue ();
64
- minLazyStringLength = PythonOptions .MinLazyStringLength .getDefaultValue ();
56
+ if (ImageInfo .inImageBuildtimeCode ()) {
57
+ MinLazyStringLength = PythonOptions .MinLazyStringLength .getDefaultValue ();
58
+ UseLazyStrings = PythonOptions .LazyStrings .getDefaultValue ();
59
+ } else {
60
+ MinLazyStringLength = PythonOptions .getMinLazyStringLength ();
61
+ UseLazyStrings = PythonOptions .useLazyString ();
65
62
}
66
- MinLazyStringLength = minLazyStringLength ;
67
- UseLazyStrings = useLazyStrings ;
68
63
}
69
64
70
65
public static int length (CharSequence cs , ConditionProfile profile1 , ConditionProfile profile2 ) {
0 commit comments