Skip to content

Commit cc7e780

Browse files
committed
Re-use shared WASM Prism instance
The parser should be stateless and a new machine is constructed for each call, so we should be able to reuse the same Prism instance across parses.
1 parent b094616 commit cc7e780

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/main/java/org/jruby/prism/parser/ParserPrismWasm.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
import static org.jruby.parser.ParserType.EVAL;
2525

2626
public class ParserPrismWasm extends ParserPrismBase {
27+
private static final Prism prism = new Prism();
28+
2729
public ParserPrismWasm(Ruby runtime) {
2830
super(runtime);
2931
}
3032

3133
protected byte[] parse(byte[] source, int sourceLength, byte[] metadata) {
32-
try (Prism prism = new Prism()) {
33-
return prism.serialize(metadata, source, sourceLength);
34-
}
34+
return prism.serialize(metadata, source, sourceLength);
3535
}
3636
}

0 commit comments

Comments
 (0)