mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 01:24:33 +02:00
8198816: AbstractScriptEngine.getScriptContext creation of SimpleScriptContext is inefficient
Reviewed-by: sundar, jlaskey
This commit is contained in:
parent
60723b7e3d
commit
54d482220b
3 changed files with 19 additions and 12 deletions
|
@ -86,11 +86,25 @@ public class SimpleScriptContext implements ScriptContext {
|
|||
* Create a {@code SimpleScriptContext}.
|
||||
*/
|
||||
public SimpleScriptContext() {
|
||||
this(new InputStreamReader(System.in),
|
||||
new PrintWriter(System.out , true),
|
||||
new PrintWriter(System.err, true));
|
||||
engineScope = new SimpleBindings();
|
||||
globalScope = null;
|
||||
reader = new InputStreamReader(System.in);
|
||||
writer = new PrintWriter(System.out , true);
|
||||
errorWriter = new PrintWriter(System.err, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Package-private constructor to avoid needless creation of reader and writers.
|
||||
* It is the caller's responsability to initialize the engine scope.
|
||||
*
|
||||
* @param reader the reader
|
||||
* @param writer the writer
|
||||
* @param errorWriter the error writer
|
||||
*/
|
||||
SimpleScriptContext(Reader reader, Writer writer, Writer errorWriter) {
|
||||
this.reader = reader;
|
||||
this.writer = writer;
|
||||
this.errorWriter = errorWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue