harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r741072 - /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
Date Thu, 05 Feb 2009 10:48:30 GMT
Author: sjanuary
Date: Thu Feb  5 10:48:29 2009
New Revision: 741072

URL: http://svn.apache.org/viewvc?rev=741072&view=rev
Log:
Pack200 - improved size estimate for multiple segments

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java?rev=741072&r1=741071&r2=741072&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
Thu Feb  5 10:48:29 2009
@@ -147,8 +147,12 @@
         if(segmentLimit != -1 && segmentLimit != 0) {
             // -1 is a special case where only one segment is created and
             // 0 is a special case where one segment is created for each file
-            int packedSize = name.endsWith(".class") ? estimatePackedSize(size)
-                    : (int) size;
+
+            // This is fairly close to the RI, but still a little smaller as the exact sum
is not given in the spec.
+            int packedSize  = (int)size // size of the file
+                    + 24 // 3x8 bytes for 3 longs in file_modtime, file_options and file_size
bands
+                    + (name.endsWith(".class") ? 1 : name.getBytes().length); // size of
entry in file_name band
+
             if (packedSize + currentSegmentSize > segmentLimit) {
                 return false;
             } else {
@@ -169,10 +173,6 @@
         return true;
     }
 
-    private int estimatePackedSize(long size) {
-        return (int) size; // TODO: try to match the RI as closely as possible
-    }
-
     static class File {
 
         private final String name;



Mime
View raw message