+
+#if 1
+ /* Optimization enabled by default: if we're writing all the images,
+ * it's not strictly necessary to decompress, parse, and go through the
+ * dentry tree in each image's metadata resource. Instead, include all
+ * the hashed streams referenced from the lookup table as well as all
+ * unhashed streams referenced in the per-image list. For 'out_refcnt'
+ * for each stream, just copy the value from 'refcnt', which is the
+ * reference count of that stream in the entire WIM. */
+ if (image == WIMLIB_ALL_IMAGES) {
+ struct wim_lookup_table_entry *lte;
+ struct wim_image_metadata *imd;
+ unsigned i;
+
+ for_lookup_table_entry(wim->lookup_table,
+ do_lte_reference_for_write, &ctx);
+ for (i = 0; i < wim->hdr.image_count; i++) {
+ imd = wim->image_metadata[i];
+ image_for_each_unhashed_stream(lte, imd)
+ do_lte_reference_for_write(lte, &ctx);
+ }
+ ret = 0;
+ } else
+#endif
+ ret = for_image(wim, image, image_find_streams_to_write);
+