changeset 364:1a464e090538 0.3

simplify table code
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 16 Apr 2015 11:51:21 -0600
parents 17b02b56d806
children 7669814ce6f1
files core/src/luan/AbstractLuanTable.java core/src/luan/LuanPropertyTable.java core/src/luan/LuanTableImpl.java
diffstat 3 files changed, 2 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/AbstractLuanTable.java	Thu Apr 16 10:12:58 2015 -0600
+++ b/core/src/luan/AbstractLuanTable.java	Thu Apr 16 11:51:21 2015 -0600
@@ -20,10 +20,6 @@
 		return new LinkedHashMap<Object,Object>();
 	}
 
-	protected final Map<Object,Object> newMap(Map<Object,Object> map) {
-		return new LinkedHashMap<Object,Object>(map);
-	}
-
 	@Override public boolean isEmpty() {
 		return isList() && length()==0;
 	}
@@ -91,7 +87,7 @@
 	}
 
 	@Override public LuanTable cloneTable() {
-		return isList() ? new LuanTableImpl(new ArrayList<Object>(asList())) : new LuanTableImpl(newMap(asMap()));
+		return isList() ? new LuanTableImpl(new ArrayList<Object>(asList())) : new LuanTableImpl(asMap());
 	}
 
 	@Override public boolean hasJava() {
--- a/core/src/luan/LuanPropertyTable.java	Thu Apr 16 10:12:58 2015 -0600
+++ b/core/src/luan/LuanPropertyTable.java	Thu Apr 16 11:51:21 2015 -0600
@@ -55,12 +55,4 @@
 		};
 	}
 
-	@Override public Map<Object,Object> asMap() {
-		Map<Object,Object> map = newMap();
-		for( Map.Entry<Object,Object> entry : this ) {
-			map.put(entry.getKey(),entry.getValue());
-		}
-		return map;
-	}
-
 }
--- a/core/src/luan/LuanTableImpl.java	Thu Apr 16 10:12:58 2015 -0600
+++ b/core/src/luan/LuanTableImpl.java	Thu Apr 16 11:51:21 2015 -0600
@@ -21,14 +21,7 @@
 	private boolean hasJava = false;
 
 	public LuanTableImpl() {}
-/*
-	public LuanTableImpl(LuanTableImpl tbl) {
-		if( tbl.map != null )
-			this.map = newMap(tbl.map);
-		if( tbl.list != null )
-			this.list = new ArrayList<Object>(tbl.list);
-	}
-*/
+
 	LuanTableImpl(List<Object> list) {
 		this.list = list;
 		this.map = newMap();
@@ -88,17 +81,6 @@
 		return list!=null ? list : Collections.emptyList();
 	}
 
-	@Override public Map<Object,Object> asMap() {
-		if( list == null || list.isEmpty() )
-			return map();
-		Map<Object,Object> rtn = map!=null ? newMap(map) : newMap();
-		for( ListIterator iter = list.listIterator(); iter.hasNext(); ) {
-			int i = iter.nextIndex();
-			rtn.put(i+1,iter.next());
-		}
-		return rtn;
-	}
-
 	@Override protected Map<Object,Object> map() {
 		return map!=null ? map : Collections.emptyMap();
 	}