diff core/src/luan/impl/SetTableEntry.java @ 224:05eb2837ddbf

change LuanTable.put() to not return old value git-svn-id: https://luan-java.googlecode.com/svn/trunk@225 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 21 Jul 2014 09:27:06 +0000
parents b76fcb72d97d
children d55e873e1f0d
line wrap: on
line diff
--- a/core/src/luan/impl/SetTableEntry.java	Mon Jul 21 06:38:01 2014 +0000
+++ b/core/src/luan/impl/SetTableEntry.java	Mon Jul 21 09:27:06 2014 +0000
@@ -25,20 +25,17 @@
 		Object h;
 		if( t instanceof LuanTable ) {
 			LuanTable table = (LuanTable)t;
-			Object old;
-			try {
-				old = table.put(key,value);
-			} catch(IllegalArgumentException e) {
-				throw luan.bit(se).exception(e);
-			} catch(UnsupportedOperationException e) {
-				throw luan.bit(se).exception(e);
+			h = luan.getHandler("__newindex",table);
+			if( h==null || table.get(key)!=null ) {
+				try {
+					table.put(key,value);
+				} catch(IllegalArgumentException e) {
+					throw luan.bit(se).exception(e);
+				} catch(UnsupportedOperationException e) {
+					throw luan.bit(se).exception(e);
+				}
+				return;
 			}
-			if( old != null )
-				return;
-			h = luan.getHandler("__newindex",t);
-			if( h==null )
-				return;
-			table.put(key,old);
 		} else {
 			h = luan.getHandler("__newindex",t);
 			if( h==null )