summaryrefslogtreecommitdiff
path: root/src/cli/runtime/PersistentArrayMap.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/runtime/PersistentArrayMap.cs')
-rw-r--r--src/cli/runtime/PersistentArrayMap.cs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cli/runtime/PersistentArrayMap.cs b/src/cli/runtime/PersistentArrayMap.cs
index f6a30be7..ebb217a4 100644
--- a/src/cli/runtime/PersistentArrayMap.cs
+++ b/src/cli/runtime/PersistentArrayMap.cs
@@ -29,7 +29,9 @@ public class PersistentArrayMap : IPersistentMap, ISequential {
internal readonly Object[] array;
-public PersistentArrayMap(){
+ public static PersistentArrayMap EMPTY = new PersistentArrayMap();
+
+protected PersistentArrayMap(){
this.array = RT.EMPTY_ARRAY;
}
@@ -86,7 +88,10 @@ public IPersistentMap remove(Object key) {
int i = indexOf(key);
if(i >= 0) //have key, will remove
{
- Object[] newArray = new Object[array.Length - 2];
+ int newlen = array.Length - 2;
+ if (newlen == 0)
+ return empty();
+ Object[] newArray = new Object[newlen];
for(int s=0,d=0;s<array.Length;s += 2)
{
if(!equalKey(array[s],key)) //skip removal key
@@ -102,6 +107,10 @@ public IPersistentMap remove(Object key) {
return this;
}
+virtual public IPersistentMap empty() {
+ return EMPTY;
+}
+
public Object get(Object key) {
int i = indexOf(key);
if(i >= 0)