36
36
import java .io .OutputStream ;
37
37
import java .nio .file .LinkOption ;
38
38
import java .text .MessageFormat ;
39
+ import java .util .ArrayDeque ;
39
40
import java .util .ArrayList ;
40
41
import java .util .HashMap ;
41
42
import java .util .List ;
42
- import java .util .Stack ;
43
43
import java .util .concurrent .atomic .AtomicLong ;
44
44
import java .util .concurrent .locks .ReentrantLock ;
45
45
import java .util .function .Supplier ;
@@ -145,7 +145,7 @@ public final class PythonContext {
145
145
146
146
// A thread-local to store the full path to the currently active import statement, for Jython
147
147
// compat
148
- private final ThreadLocal <Stack <String >> currentImport = new ThreadLocal <>();
148
+ private final ThreadLocal <ArrayDeque <String >> currentImport = new ThreadLocal <>();
149
149
150
150
public PythonContext (PythonLanguage language , TruffleLanguage .Env env , PythonCore core ) {
151
151
this .language = language ;
@@ -729,10 +729,8 @@ public boolean isPyFileInLanguageHome(TruffleFile path) {
729
729
730
730
@ TruffleBoundary
731
731
public String getCurrentImport () {
732
- Stack <String > ci = currentImport .get ();
733
- if (ci == null ) {
734
- return "" ;
735
- } else if (ci .isEmpty ()) {
732
+ ArrayDeque <String > ci = currentImport .get ();
733
+ if (ci == null || ci .isEmpty ()) {
736
734
return "" ;
737
735
} else {
738
736
return ci .peek ();
@@ -741,9 +739,9 @@ public String getCurrentImport() {
741
739
742
740
@ TruffleBoundary
743
741
public void pushCurrentImport (String object ) {
744
- Stack <String > ci = currentImport .get ();
742
+ ArrayDeque <String > ci = currentImport .get ();
745
743
if (ci == null ) {
746
- ci = new Stack <>();
744
+ ci = new ArrayDeque <>();
747
745
currentImport .set (ci );
748
746
}
749
747
ci .push (object );
0 commit comments