[MLton-commit] r7351

Wesley Terpstra wesley at mlton.org
Mon Nov 2 13:50:00 PST 2009


Re-order identifiers to trick windows cabinet into making a good decision.


----------------------------------------------------------------------

U   mlton/trunk/package/mingw/dirs2wix.sml
U   mlton/trunk/package/mingw/files2cmp.sml
U   mlton/trunk/package/mingw/files2wix.sml
U   mlton/trunk/package/mingw/mlton.wxs.in

----------------------------------------------------------------------

Modified: mlton/trunk/package/mingw/dirs2wix.sml
===================================================================
--- mlton/trunk/package/mingw/dirs2wix.sml	2009-11-02 19:53:58 UTC (rev 7350)
+++ mlton/trunk/package/mingw/dirs2wix.sml	2009-11-02 21:49:53 UTC (rev 7351)
@@ -8,12 +8,29 @@
    \  </Fragment>\n\
    \</Wix>\n"
 
+(* Identifiers must be unique per path.
+ *   => Therefore we include a 64-bit hash.
+ *      + Careful: / and \ must hash the same.
+ * They must also be alphanumeric and less than 78 bytes.
+ *   => We convert non-alnums to _
+ *   => We trim the filename to the last 40 bytes.
+ * 
+ * The contents of the installer cab are sorted by the identifier we choose.
+ * Similar files compress better when they are near each other.
+ *   => Use: rev(filename).hash as the identifier
+ *      + Sorts first by file-type
+ *      + Same-named files (in different directories) get clumped together.
+ *)
 fun slashes c = if c = #"\\" then #"/" else c
 fun hash (c, w) = w * 0w5746711073709751657 + Word64.fromInt (Char.ord (slashes c))
 fun alnum c = if Char.isAlphaNum c orelse c = #"." then c else #"_"
 fun trim s = if String.size s > 40 then String.substring (s, 0, 40) else s
-fun escape s = Word64.toString (foldl hash 0w0 (explode s)) ^ "." ^ 
-               trim (CharVector.map alnum (#file (OS.Path.splitDirFile s)))
+fun rev s = 
+   let val len = CharVector.length s in
+   CharVector.tabulate (len, fn i => CharVector.sub (s, len-1-i)) end
+fun escape s =
+   (trim o rev o CharVector.map alnum o #file o OS.Path.splitDirFile) s
+   ^ "." ^ Word64.toString (foldl hash 0w0 (explode s))
 
 val depth = ref 3
 fun pad () = CharVector.tabulate (!depth * 2, fn _ => #" ")

Modified: mlton/trunk/package/mingw/files2cmp.sml
===================================================================
--- mlton/trunk/package/mingw/files2cmp.sml	2009-11-02 19:53:58 UTC (rev 7350)
+++ mlton/trunk/package/mingw/files2cmp.sml	2009-11-02 21:49:53 UTC (rev 7351)
@@ -14,12 +14,29 @@
    \  </Fragment>\n\
    \</Wix>\n"
 
+(* Identifiers must be unique per path.
+ *   => Therefore we include a 64-bit hash.
+ *      + Careful: / and \ must hash the same.
+ * They must also be alphanumeric and less than 78 bytes.
+ *   => We convert non-alnums to _
+ *   => We trim the filename to the last 40 bytes.
+ * 
+ * The contents of the installer cab are sorted by the identifier we choose.
+ * Similar files compress better when they are near each other.
+ *   => Use: rev(filename).hash as the identifier
+ *      + Sorts first by file-type
+ *      + Same-named files (in different directories) get clumped together.
+ *)
 fun slashes c = if c = #"\\" then #"/" else c
 fun hash (c, w) = w * 0w5746711073709751657 + Word64.fromInt (Char.ord (slashes c))
 fun alnum c = if Char.isAlphaNum c orelse c = #"." then c else #"_"
 fun trim s = if String.size s > 40 then String.substring (s, 0, 40) else s
-fun escape s = Word64.toString (foldl hash 0w0 (explode s)) ^ "." ^ 
-               trim (CharVector.map alnum (#file (OS.Path.splitDirFile s)))
+fun rev s = 
+   let val len = CharVector.length s in
+   CharVector.tabulate (len, fn i => CharVector.sub (s, len-1-i)) end
+fun escape s =
+   (trim o rev o CharVector.map alnum o #file o OS.Path.splitDirFile) s
+   ^ "." ^ Word64.toString (foldl hash 0w0 (explode s))
 
 fun component path = 
    case OS.Path.splitDirFile path of {file, dir} =>

Modified: mlton/trunk/package/mingw/files2wix.sml
===================================================================
--- mlton/trunk/package/mingw/files2wix.sml	2009-11-02 19:53:58 UTC (rev 7350)
+++ mlton/trunk/package/mingw/files2wix.sml	2009-11-02 21:49:53 UTC (rev 7351)
@@ -12,12 +12,29 @@
    \  </Fragment>\n\
    \</Wix>\n"
 
+(* Identifiers must be unique per path.
+ *   => Therefore we include a 64-bit hash.
+ *      + Careful: / and \ must hash the same.
+ * They must also be alphanumeric and less than 78 bytes.
+ *   => We convert non-alnums to _
+ *   => We trim the filename to the last 40 bytes.
+ * 
+ * The contents of the installer cab are sorted by the identifier we choose.
+ * Similar files compress better when they are near each other.
+ *   => Use: rev(filename).hash as the identifier
+ *      + Sorts first by file-type
+ *      + Same-named files (in different directories) get clumped together.
+ *)
 fun slashes c = if c = #"\\" then #"/" else c
 fun hash (c, w) = w * 0w5746711073709751657 + Word64.fromInt (Char.ord (slashes c))
 fun alnum c = if Char.isAlphaNum c orelse c = #"." then c else #"_"
 fun trim s = if String.size s > 40 then String.substring (s, 0, 40) else s
-fun escape s = Word64.toString (foldl hash 0w0 (explode s)) ^ "." ^ 
-               trim (CharVector.map alnum (#file (OS.Path.splitDirFile s)))
+fun rev s = 
+   let val len = CharVector.length s in
+   CharVector.tabulate (len, fn i => CharVector.sub (s, len-1-i)) end
+fun escape s =
+   (trim o rev o CharVector.map alnum o #file o OS.Path.splitDirFile) s
+   ^ "." ^ Word64.toString (foldl hash 0w0 (explode s))
 
 fun dirEntry path =
    let

Modified: mlton/trunk/package/mingw/mlton.wxs.in
===================================================================
--- mlton/trunk/package/mingw/mlton.wxs.in	2009-11-02 19:53:58 UTC (rev 7350)
+++ mlton/trunk/package/mingw/mlton.wxs.in	2009-11-02 21:49:53 UTC (rev 7351)
@@ -48,14 +48,14 @@
       <Directory Id="DesktopFolder" Name="Desktop" />
     </Directory>
 
-    <DirectoryRef Id='dir.5CF63DEB372EF117.mlton'>
+    <DirectoryRef Id='dir.notlm.5CF63DEB372EF117'>
       <Component Id='component.documentation' Guid='1E019F99-0424-8133-D4F6-C7DDA0882798'>
         <RegistryValue Root='HKCU' Key='SOFTWARE\MLton.org\MLton\docs' Type='string' Value='' KeyPath='yes' />
         <Shortcut Id='start_docs' Directory='ProgramMenuDir' Name='Documentation' Description='The MLton documentation folder'/>
       </Component>
     </DirectoryRef>
 
-    <DirectoryRef Id='dir.7746DD2CF59E4101.bin'>
+    <DirectoryRef Id='dir.nib.7746DD2CF59E4101'>
       <Component Id='component.path' Guid='5B06C123-B426-3D4D-BE48-4D07BAD8A6BA'>
         <RegistryValue Root='HKCU' Key='SOFTWARE\MLton.org\MLton\path' Type='string' Value='' KeyPath='yes' />
         <Environment Id='env.path' Name='PATH' Action='set' Part='last' System='yes' Value='[dir.bin]' />




More information about the MLton-commit mailing list