[armedbear-cvs] r11672 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Thu Feb 19 22:13:34 UTC 2009


Author: ehuelsmann
Date: Thu Feb 19 22:13:31 2009
New Revision: 11672

Log:
Remove code duplication: use loadCompiledFunction(InputStream, int) instead of inlining code
  to the same extent.

Modified:
   trunk/abcl/src/org/armedbear/lisp/Lisp.java

Modified: trunk/abcl/src/org/armedbear/lisp/Lisp.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Lisp.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Lisp.java	Thu Feb 19 22:13:31 2009
@@ -1010,39 +1010,8 @@
                               {
                                 long size = entry.getSize();
                                 InputStream in = zipFile.getInputStream(entry);
-                                byte[] bytes = new byte[(int)size];
-                                int bytesRemaining = (int) size;
-                                int bytesRead = 0;
-                                while (bytesRemaining > 0)
-                                  {
-                                    int n;
-                                    if (bytesRemaining >= 4096)
-                                      n = in.read(bytes, bytesRead, 4096);
-                                    else
-                                      n = in.read(bytes, bytesRead, bytesRemaining);
-                                    if (n < 0)
-                                      break;
-                                    bytesRead += n;
-                                    bytesRemaining -= n;
-                                  }
-                                in.close();
-                                if (bytesRemaining > 0)
-                                  Debug.trace("bytesRemaining = " + bytesRemaining);
-                                JavaClassLoader loader = new JavaClassLoader();
-                                Class c =
-                                  loader.loadClassFromByteArray(null, bytes, 0, bytes.length);
-                                if (c != null)
-                                  {
-                                    Class[] parameterTypes = new Class[0];
-                                    Constructor constructor =
-                                      c.getConstructor(parameterTypes);
-                                    Object[] initargs = new Object[0];
-                                    LispObject obj =
-                                      (LispObject) constructor.newInstance(initargs);
-                                    if (obj instanceof Function)
-                                      ((Function)obj).setClassBytes(bytes);
-                                    return obj != null ? obj : NIL;
-                                  }
+                                LispObject obj = loadCompiledFunction(in, (int) size);
+                                return obj != null ? obj : NIL;
                               }
                           }
                         finally




More information about the armedbear-cvs mailing list