+ /*
+ * We normally sort the streams to write by a "sequential" order that is
+ * optimized for reading. But when using solid compression, we instead
+ * sort the streams by file extension and file name (when applicable;
+ * and we don't do this for streams from solid resources) so that
+ * similar files are grouped together, which improves the compression
+ * ratio. This is somewhat of a hack since a stream does not
+ * necessarily correspond one-to-one with a filename, nor is there any
+ * guarantee that two files with similar names or extensions are
+ * actually similar in content. A potential TODO is to sort the streams
+ * based on some measure of similarity of their actual contents.
+ */
+
+ ret = sort_stream_list_by_sequential_order(stream_list,
+ offsetof(struct wim_lookup_table_entry,
+ write_streams_list));
+ if (ret)
+ return ret;
+
+ compute_stream_list_stats(stream_list, &ctx);
+
+ if (write_resource_flags & WRITE_RESOURCE_FLAG_SOLID) {
+ ret = sort_stream_list_for_solid_compression(stream_list);
+ if (unlikely(ret))
+ WARNING("Failed to sort streams for solid compression. Continuing anyways.");
+ }
+