Skip to content

Commit fe1772a

Browse files
jafingerhutstuarthalloway
authored andcommitted
CLJ-1295: Speed up dissoc on array-maps
Signed-off-by: Stuart Halloway <stu@cognitect.com>
1 parent 25221df commit fe1772a

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

src/jvm/clojure/lang/PersistentArrayMap.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,8 @@ public IPersistentMap without(Object key){
218218
if(newlen == 0)
219219
return empty();
220220
Object[] newArray = new Object[newlen];
221-
for(int s = 0, d = 0; s < array.length; s += 2)
222-
{
223-
if(!equalKey(array[s], key)) //skip removal key
224-
{
225-
newArray[d] = array[s];
226-
newArray[d + 1] = array[s + 1];
227-
d += 2;
228-
}
229-
}
221+
System.arraycopy(array, 0, newArray, 0, i);
222+
System.arraycopy(array, i+2, newArray, i, newlen - i);
230223
return create(newArray);
231224
}
232225
//don't have key, no op

0 commit comments

Comments
 (0)