summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2006-08-09 13:17:11 +0000
committerRich Hickey <richhickey@gmail.com>2006-08-09 13:17:11 +0000
commite5fafd352e9351e1f55b1fac0de911e1dc3b632a (patch)
tree3b843f02530b4d38b13dd49f1487791110900f8e /src
parent108db3bc660f25860a201fbd2769ef2640f300bf (diff)
removed chaining from ArraySeq.rest, changed meta handling in queue
Diffstat (limited to 'src')
-rw-r--r--src/jvm/clojure/lang/ArraySeq.java21
-rw-r--r--src/jvm/clojure/lang/PersistentQueue.java17
2 files changed, 19 insertions, 19 deletions
diff --git a/src/jvm/clojure/lang/ArraySeq.java b/src/jvm/clojure/lang/ArraySeq.java
index 191e5f80..d9af61a1 100644
--- a/src/jvm/clojure/lang/ArraySeq.java
+++ b/src/jvm/clojure/lang/ArraySeq.java
@@ -15,7 +15,7 @@ package clojure.lang;
public class ArraySeq extends ASeq implements IndexedSeq{
final Object[] array;
final int i;
-ISeq _rest;
+//ISeq _rest;
static public ArraySeq create(Object... array){
if(array.length == 0)
@@ -26,7 +26,7 @@ static public ArraySeq create(Object... array){
ArraySeq(Object[] array, int i){
this.array = array;
this.i = i;
- this._rest = this;
+// this._rest = this;
}
public Object first() {
@@ -34,13 +34,16 @@ public Object first() {
}
public ISeq rest() {
- if(_rest == this)
- {
- if(i+1 < array.length)
- _rest = new ArraySeq(array, i + 1);
- _rest = null;
- }
- return _rest;
+ if(i+1 < array.length)
+ return new ArraySeq(array, i + 1);
+ return null;
+// if(_rest == this)
+// {
+// if(i+1 < array.length)
+// _rest = new ArraySeq(array, i + 1);
+// _rest = null;
+// }
+// return _rest;
}
public int index(){
diff --git a/src/jvm/clojure/lang/PersistentQueue.java b/src/jvm/clojure/lang/PersistentQueue.java
index 4ba29e7d..29092f38 100644
--- a/src/jvm/clojure/lang/PersistentQueue.java
+++ b/src/jvm/clojure/lang/PersistentQueue.java
@@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
public class PersistentQueue extends Obj implements IPersistentList {
-final public static PersistentQueue EMPTY = new PersistentQueue(null,null);
+final public static PersistentQueue EMPTY = new PersistentQueue(null,null,null);
//*
final ISeq f;
@@ -31,9 +31,10 @@ final PersistentArrayList r;
static final int INITIAL_REAR_SIZE = 4;
-PersistentQueue(ISeq f, PersistentArrayList r) {
+PersistentQueue(ISeq f, PersistentArrayList r, IPersistentMap meta) {
this.f = f;
this.r = r;
+ this._meta = meta;
}
public Object peek() {
@@ -51,9 +52,7 @@ public PersistentQueue pop() {
f1 = RT.seq(r);
r1 = null;
}
- PersistentQueue ret = new PersistentQueue(f1, r1);
- ret._meta = _meta;
- return ret;
+ return new PersistentQueue(f1, r1,_meta);
}
public int count() {
@@ -69,12 +68,10 @@ public ISeq seq() {
public PersistentQueue cons(Object o) {
PersistentQueue ret;
if(f == null) //empty
- ret = new PersistentQueue(RT.list(o), null);
+ return new PersistentQueue(RT.list(o), null,_meta);
else
- ret= new PersistentQueue(f,
- (PersistentArrayList) (r != null ? r : new PersistentArrayList(INITIAL_REAR_SIZE)).cons(o));
- ret._meta = _meta;
- return ret;
+ return new PersistentQueue(f,
+ (PersistentArrayList) (r != null ? r : new PersistentArrayList(INITIAL_REAR_SIZE)).cons(o),_meta);
}
public Obj withMeta(IPersistentMap meta) {