Skip to content

Commit a7be724

Browse files
committed
Adjusted the "deferred initialization" behavior so that the embedded scripting engine is not constructed until the first evaluation. This was done because embedded scripting engine initialization got noticeably slower in JRuby 1.6.
1 parent 12051fa commit a7be724

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/jruby4max/rubysupport/MaxRubyAdapter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public MaxRubyAdapter( MaxObject maxObject, String context, String id, CompatVer
7676
this.maxContext = context;
7777
this.id = id;
7878
this.rubyVersion = rubyVersion;
79-
getEvaluator();
8079
}
8180

8281
private void getEvaluator() {
@@ -135,7 +134,7 @@ public Object eval( CharSequence rubyCode ) {
135134
* @return an Atom or Atom[], it's up to the calling code to check the type
136135
*/
137136
public Object eval( CharSequence rubyCode, boolean returnResult ) {
138-
if( !ruby.isInitialized() ) {
137+
if( ruby == null || !ruby.isInitialized() ) {
139138
init();
140139
}
141140
Object result;
@@ -158,6 +157,9 @@ public void init() {
158157
}
159158

160159
public void init( File file, Atom[] args ) {
160+
if (ruby == null) {
161+
getEvaluator();
162+
}
161163
if( code.isEmpty() ) {
162164
// setup the $LOAD_PATH
163165
for( String loadPath : RubyProperties.getLoadPaths() ) {

0 commit comments

Comments
 (0)