Skip to content

Commit

Permalink
less getRuntime (internal) invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Feb 17, 2015
1 parent cd90361 commit cb7886e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/java/arjdbc/ArJdbcModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static void warn(final ThreadContext context, final String message) {
@JRubyMethod(name = "load_java_part", meta = true, required = 1, optional = 2)
public static IRubyObject load_java_part(final ThreadContext context,
final IRubyObject self, final IRubyObject[] args) {
final Ruby runtime = context.getRuntime();
final Ruby runtime = context.runtime;

String connectionClass = args.length > 1 ? args[1].toString() : null;
String moduleClass = args.length > 2 ? args[2].toString() : null;
Expand Down Expand Up @@ -171,7 +171,7 @@ public static IRubyObject load_java_part(final ThreadContext context,
*/
@JRubyMethod(name = "modules", meta = true)
public static IRubyObject modules(final ThreadContext context, final IRubyObject self) {
final Ruby runtime = context.getRuntime();
final Ruby runtime = context.runtime;
final RubyModule arJdbc = (RubyModule) self;

final Collection<String> constants = arJdbc.getConstantNames();
Expand Down
13 changes: 7 additions & 6 deletions src/java/arjdbc/jdbc/RubyJdbcConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ protected void doInitialize(final ThreadContext context, final IRubyObject confi

@JRubyMethod(name = "adapter")
public final IRubyObject adapter() {
return getAdapter() == null ? getRuntime().getNil() : getAdapter();
final IRubyObject adapter = getAdapter();
return adapter == null ? getRuntime().getNil() : adapter;
}

/**
Expand Down Expand Up @@ -609,9 +610,9 @@ private void configureConnection() {
}

@JRubyMethod(name = "configure_connection")
public IRubyObject configure_connection() {
public IRubyObject configure_connection(final ThreadContext context) {
if ( ! lazy || getConnectionImpl() != null ) configureConnection();
return getRuntime().getNil();
return context.nil;
}

@JRubyMethod(name = "jdbc_connection", alias = "connection")
Expand Down Expand Up @@ -1688,7 +1689,7 @@ private ConnectionFactory setDriverFactory(final ThreadContext context) {
}
else {
setConnectionFactory(factory = new RubyConnectionFactoryImpl(
driver_instance, context.getRuntime().newString(jdbcURL),
driver_instance, context.runtime.newString(jdbcURL),
( username.isNil() ? username : username.asString() ),
( password.isNil() ? password : password.asString() )
));
Expand Down Expand Up @@ -1734,7 +1735,7 @@ protected DriverWrapper newDriverWrapper(final ThreadContext context, final Stri
@JRubyMethod(visibility = Visibility.PRIVATE)
public IRubyObject jdbc_url(final ThreadContext context) throws NamingException {
final IRubyObject url = getConfigValue(context, "url");
return context.getRuntime().newString( buildURL(context, url) );
return context.runtime.newString( buildURL(context, url) );
}

private String buildURL(final ThreadContext context, final IRubyObject url) {
Expand Down Expand Up @@ -4149,7 +4150,7 @@ protected static IRubyObject raise(final ThreadContext context, final RubyClass
}
protected static IRubyObject raise(final ThreadContext context, final RubyClass error, final String message, final Throwable cause) {
final Ruby runtime = context.getRuntime();
final Ruby runtime = context.runtime;
final IRubyObject[] args;
if ( message != null ) {
args = new IRubyObject[] { error, runtime.newString(message) };
Expand Down
2 changes: 1 addition & 1 deletion src/java/arjdbc/oracle/OracleRubyJdbcConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public IRubyObject call(final Connection connection) throws SQLException {
statement.registerOutParameter(outIndex, outType);
statement.executeUpdate();
ResultSet resultSet = new CallResultSet(statement);
return jdbcToRuby(context, context.getRuntime(), outIndex, outType, resultSet);
return jdbcToRuby(context, context.runtime, outIndex, outType, resultSet);
}
catch (final SQLException e) {
debugErrorSQL(context, query);
Expand Down

0 comments on commit cb7886e

Please sign in to comment.