diff core/src/luan/impl/LuanImpl.java @ 674:2994e46f62b7

some optimization
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Apr 2016 19:31:18 -0600
parents d3e5414bdf4c
children 41f791e4206d
line wrap: on
line diff
--- a/core/src/luan/impl/LuanImpl.java	Tue Apr 12 17:09:06 2016 -0600
+++ b/core/src/luan/impl/LuanImpl.java	Tue Apr 12 19:31:18 2016 -0600
@@ -14,20 +14,6 @@
 public final class LuanImpl {
 	private LuanImpl() {}  // never
 
-/*
-	private static List list = new ArrayList();
-
-	static int addObj(Object obj) {
-		int i = list.size();
-		list.add(obj);
-		return i;
-	}
-
-	public static Object getObj(int i) {
-		return list.get(i);
-	}
-*/
-
 	public static int len(LuanState luan,Object o) throws LuanException {
 		if( o instanceof String ) {
 			String s = (String)o;
@@ -191,10 +177,7 @@
 		return i<a.length ? a[i] : null;
 	}
 
-	public static Object[] varArgs(Object o,int i) {
-		if( !(o instanceof Object[]) )
-			return i==0 ? new Object[]{o} : LuanFunction.NOTHING;
-		Object[] a = (Object[])o;
+	public static Object[] varArgs(Object[] a,int i) {
 		if( i >= a.length )
 			return LuanFunction.NOTHING;
 		Object[] rtn = new Object[a.length - i];
@@ -233,10 +216,10 @@
 		}
 	}
 
-	public static LuanTable table(Object o) {
+	public static LuanTable table(Object[] a) {
 		LuanTable table = new LuanTable();
 		int i = 0;
-		for( Object fld : Luan.array(o) ) {
+		for( Object fld : a ) {
 			if( fld instanceof TableField ) {
 				TableField tblFld = (TableField)fld;
 				Object key = tblFld.key;
@@ -252,4 +235,8 @@
 		return table;
 	}
 
+	public static Object first(Object[] a) {
+		return a.length==0 ? null : a[0];
+	}
+
 }