Permalink
Browse files

Eliminate a couple more JavaArray accesses (JRUBY-4732).

  • Loading branch information...
headius committed Sep 19, 2012
1 parent 39674bf commit d8b91a00f26454b228a6dcb4ab5fd13d03794dbd
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/org/jruby/java/proxies/ArrayJavaProxy.java
@@ -1,5 +1,6 @@
package org.jruby.java.proxies;
+import java.lang.reflect.Array;
import java.util.Arrays;
import org.jruby.Ruby;
import org.jruby.RubyClass;
@@ -51,13 +52,13 @@ public JavaArray getJavaArray() {
}
@JRubyMethod(name = {"length","size"})
- public IRubyObject length() {
- return getJavaArray().length();
+ public IRubyObject length(ThreadContext context) {
+ return context.runtime.newFixnum(Array.getLength(this.getObject()));
}
@JRubyMethod(name = "empty?")
public IRubyObject empty(ThreadContext context) {
- return RubyFixnum.zero(context.runtime).eql_p(getJavaArray().length());
+ return context.runtime.newBoolean(Array.getLength(this.getObject()) == 0);
}
@JRubyMethod(name = "[]")

0 comments on commit d8b91a0

Please sign in to comment.