Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/org/jruby/RubyProc.java b/src/org/jruby/RubyProc.java
- index 1b9ac4b..296ef11 100644
- --- a/src/org/jruby/RubyProc.java
- +++ b/src/org/jruby/RubyProc.java
- @@ -196,7 +196,7 @@ public class RubyProc extends RubyObject implements JumpTarget {
- assert args != null;
- Ruby runtime = getRuntime();
- - Block newBlock = block;//.cloneBlock();
- + Block newBlock = block;
- JumpTarget jumpTarget = newBlock.getBinding().getFrame().getJumpTarget();
- try {
- diff --git a/src/org/jruby/ast/ListNode.java b/src/org/jruby/ast/ListNode.java
- index 0b12e4b..013a0ab 100644
- --- a/src/org/jruby/ast/ListNode.java
- +++ b/src/org/jruby/ast/ListNode.java
- @@ -30,6 +30,7 @@
- package org.jruby.ast;
- import java.util.ArrayList;
- +import java.util.Collections;
- import java.util.List;
- import org.jruby.ast.visitor.NodeVisitor;
- import org.jruby.lexer.yacc.ISourcePosition;
- @@ -41,6 +42,7 @@ import org.jruby.lexer.yacc.ISourcePosition;
- * the editor projects who want position info saved.
- */
- public class ListNode extends Node {
- + private Node firstNode;
- private List<Node> list;
- /**
- @@ -51,15 +53,12 @@ public class ListNode extends Node {
- */
- public ListNode(ISourcePosition position, Node firstNode) {
- this(position);
- -
- - list = new ArrayList<Node>(4);
- - list.add(firstNode);
- +
- + this.firstNode = firstNode;
- }
- public ListNode(ISourcePosition position) {
- super(position);
- -
- - list = new ArrayList<Node>(0);
- }
- public NodeType getNodeType() {
- @@ -67,6 +66,13 @@ public class ListNode extends Node {
- }
- public ListNode add(Node node) {
- + if (firstNode == null) {
- + firstNode = node;
- + return this;
- + } else if (list == null) {
- + list = new ArrayList<Node>(4);
- + }
- +
- // Ruby Grammar productions return plenty of nulls.
- if (node == null || node == NilImplicitNode.NIL) {
- list.add(NilImplicitNode.NIL);
- @@ -88,15 +94,31 @@ public class ListNode extends Node {
- public ListNode prepend(Node node) {
- // Ruby Grammar productions return plenty of nulls.
- if (node == null) return this;
- -
- - list.add(0, node);
- +
- + if (firstNode != null) {
- + if (list == null) {
- + list = new ArrayList<Node>(4);
- + }
- + list.add(0, firstNode);
- + firstNode = node;
- + } else {
- + firstNode = node;
- + }
- setPosition(getPosition().union(node.getPosition()));
- return this;
- }
- public int size() {
- - return list.size();
- + if (firstNode != null) {
- + if (list != null) {
- + return list.size() + 1;
- + } else {
- + return 1;
- + }
- + } else {
- + return 0;
- + }
- }
- @@ -108,7 +130,9 @@ public class ListNode extends Node {
- */
- public ListNode addAll(ListNode other) {
- if (other != null && other.size() > 0) {
- - list.addAll(other.list);
- + for (int i = 0; i < other.size(); i++) {
- + add(other.get(i));
- + }
- setPosition(getPosition().union(getLast().getPosition()));
- }
- @@ -126,23 +150,47 @@ public class ListNode extends Node {
- }
- public Node getLast() {
- - return list.size() == 0 ? null : list.get(list.size() - 1);
- + if (firstNode != null) {
- + if (list != null) {
- + return list.get(list.size() - 1);
- + } else {
- + return firstNode;
- + }
- + } else {
- + return null;
- + }
- }
- public String toString() {
- String string = super.toString();
- StringBuilder b = new StringBuilder();
- - for (int i = 0; i < list.size(); i++) {
- - b.append(list.get(i));
- - if (i + 1 < list.size()) {
- - b.append(", ");
- + if (firstNode != null) {
- + b.append(firstNode);
- + if (list != null) {
- + for (Node n : list) {
- + b.append(", ");
- + b.append(n);
- + }
- }
- }
- return string + ": {" + b.toString() + "}";
- }
- public List<Node> childNodes() {
- - return list;
- + if (firstNode != null) {
- + if (list != null) {
- + List newList = new ArrayList(list.size() + 1);
- + newList.add(firstNode);
- + newList.addAll(list);
- + return newList;
- + } else {
- + List newList = new ArrayList(1);
- + newList.add(firstNode);
- + return newList;
- + }
- + } else {
- + return Collections.emptyList();
- + }
- }
- public Object accept(NodeVisitor visitor) {
- @@ -150,6 +198,12 @@ public class ListNode extends Node {
- }
- public Node get(int idx) {
- - return list.get(idx);
- + if (idx == 0) {
- + return firstNode;
- + } else if (list != null) {
- + return list.get(idx - 1);
- + } else {
- + return null;
- + }
- }
- }
- diff --git a/src/org/jruby/javasupport/JavaClass.java b/src/org/jruby/javasupport/JavaClass.java
- index 63e4156..ea4f0b1 100644
- --- a/src/org/jruby/javasupport/JavaClass.java
- +++ b/src/org/jruby/javasupport/JavaClass.java
- @@ -247,7 +247,7 @@ public class JavaClass extends JavaObject {
- // called only by initializing thread; no synchronization required
- void addMethod(Method method, Class<?> javaClass) {
- if (methods == null) {
- - methods = new ArrayList<Method>();
- + methods = new ArrayList<Method>(4);
- }
- if (!Ruby.isSecurityRestricted()) {
- method.setAccessible(true);
- @@ -259,7 +259,7 @@ public class JavaClass extends JavaObject {
- // called only by initializing thread; no synchronization required
- void addAlias(String alias) {
- if (aliases == null) {
- - aliases = new ArrayList<String>();
- + aliases = new ArrayList<String>(4);
- }
- if (!aliases.contains(alias))
- aliases.add(alias);
- @@ -283,7 +283,7 @@ public class JavaClass extends JavaObject {
- // called only by initializing thread; no synchronization required
- void addConstructor(Constructor ctor, Class<?> javaClass) {
- if (constructors == null) {
- - constructors = new ArrayList<Constructor>();
- + constructors = new ArrayList<Constructor>(4);
- }
- if (!Ruby.isSecurityRestricted()) {
- ctor.setAccessible(true);
- @@ -624,31 +624,36 @@ public class JavaClass extends JavaObject {
- }
- }
- - private void installClassConstructors(final RubyClass proxy) {
- + private synchronized void installClassConstructors(final RubyClass proxy) {
- if (constructorInstaller != null) {
- constructorInstaller.install(proxy);
- + constructorInstaller = null;
- }
- }
- - private void installClassFields(final RubyClass proxy) {
- + private synchronized void installClassFields(final RubyClass proxy) {
- for (ConstantField field : constantFields) {
- field.install(proxy);
- }
- + constantFields = null;
- }
- - private void installClassMethods(final RubyClass proxy) {
- + private synchronized void installClassMethods(final RubyClass proxy) {
- for (NamedInstaller installer : staticInstallers.values()) {
- if (installer.type == NamedInstaller.STATIC_METHOD && installer.hasLocalMethod()) {
- assignAliases((MethodInstaller) installer, staticAssignedNames);
- }
- installer.install(proxy);
- }
- + staticInstallers = null;
- +
- for (NamedInstaller installer : instanceInstallers.values()) {
- if (installer.type == NamedInstaller.INSTANCE_METHOD && installer.hasLocalMethod()) {
- assignAliases((MethodInstaller) installer, instanceAssignedNames);
- }
- installer.install(proxy);
- }
- + instanceInstallers = null;
- }
- private void setupClassConstructors(Class<?> javaClass) {
Add Comment
Please, Sign In to add comment