Mercurial Hosting > luan
diff src/luan/LuanCloner.java @ 1561:e1a13e707bf3
start immutable
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 05 Nov 2020 20:24:09 -0700 |
parents | e0cf0d108a77 |
children |
line wrap: on
line diff
--- a/src/luan/LuanCloner.java Thu Oct 22 00:33:04 2020 -0600 +++ b/src/luan/LuanCloner.java Thu Nov 05 20:24:09 2020 -0700 @@ -34,7 +34,7 @@ } public Object[] clone(Object[] obj) { - if( obj.length == 0 ) + if( obj==null || obj.length == 0 ) return obj; Object[] rtn = (Object[])cloned.get(obj); if( rtn == null ) { @@ -48,6 +48,8 @@ } public Map clone(Map obj) { + if( obj==null ) + return null; Map rtn = (Map)cloned.get(obj); if( rtn == null ) { try { @@ -57,6 +59,7 @@ } catch(IllegalAccessException e) { throw new RuntimeException(e); } + cloned.put(obj,rtn); for( Object stupid : obj.entrySet() ) { Map.Entry entry = (Map.Entry)stupid; rtn.put( get(entry.getKey()), get(entry.getValue()) ); @@ -66,6 +69,8 @@ } public Collection clone(Collection obj) { + if( obj==null ) + return null; Collection rtn = (Collection)cloned.get(obj); if( rtn == null ) { try {