Skip to content

Commit 1b8f0d2

Browse files
committed
Preliminary thread-safety of statically cached parse trees
1 parent b2866c6 commit 1b8f0d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/PythonParserImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import java.util.HashMap;
3131
import java.util.Map;
32+
import java.util.concurrent.ConcurrentHashMap;
3233
import java.util.regex.Pattern;
3334

3435
import org.antlr.v4.runtime.CharStreams;
@@ -52,7 +53,7 @@
5253
import com.oracle.truffle.api.source.SourceSection;
5354

5455
public final class PythonParserImpl implements PythonParser {
55-
private static final Map<String, ParserRuleContext> cachedParseTrees = new HashMap<>();
56+
private static final Map<String, ParserRuleContext> cachedParseTrees = new ConcurrentHashMap<>();
5657

5758
private static Python3Parser getPython3Parser(CodePointCharStream fromString) {
5859
Python3Parser parser = new Builder.Parser(fromString).build();

0 commit comments

Comments
 (0)