]> mj.ucw.cz Git - libucw.git/commitdiff
The write_merged() hook is no longer required in simple cases.
authorMartin Mares <mj@ucw.cz>
Wed, 23 May 2007 19:36:08 +0000 (21:36 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 23 May 2007 19:36:08 +0000 (21:36 +0200)
lib/sorter/sort-test.c
lib/sorter/sorter.h

index 3990254d27bab7f699976fd623c13a7461bfc25e..9a822d141847037182f8a40cf3553bd8a16d8904 100644 (file)
@@ -95,13 +95,6 @@ static inline void s2_write_merged(struct fastbuf *f, struct key2 **k, void **d
   bwrite(f, k[0], sizeof(struct key2));
 }
 
-static inline void s2_copy_merged(struct key2 **k, struct fastbuf **d UNUSED, uns n, struct fastbuf *dest)
-{
-  for (uns i=1; i<n; i++)
-    k[0]->cnt += k[i]->cnt;
-  bwrite(dest, k[0], sizeof(struct key2));
-}
-
 #define SORT_KEY_REGULAR struct key2
 #define SORT_PREFIX(x) s2_##x
 #define SORT_INPUT_FB
index c2905345e910feaa6d26da100c7894d43b21bc7e..cd5e843f84bd0930d11e18ba7879452ca1fd83e6 100644 (file)
@@ -64,7 +64,7 @@
  *                     over all given records.
  *  void PREFIX_copy_merged(SORT_KEY **keys, struct fastbuf **data, uns n, struct fastbuf *dest)
  *                     takes n records with keys in memory and data in fastbufs and writes
- *                     a single record.
+ *                     a single record. Used only if SORT_DATA_SIZE or SORT_UNIFY_WORKSPACE is defined.
  *  SORT_UNIFY_WORKSPACE(key)  gets a key and returns the amount of workspace required when merging
  *                     the given record. Defaults to 0.
  *
@@ -177,6 +177,13 @@ static inline void P(copy_data)(P(key) *key, struct fastbuf *in, struct fastbuf
 #endif
 }
 
+#if defined(SORT_UNIFY) && !defined(SORT_VAR_DATA) && !defined(SORT_UNIFY_WORKSPACE)
+static inline void P(copy_merged)(P(key) **keys, struct fastbuf **data UNUSED, uns n, struct fastbuf *dest)
+{
+  P(write_merged)(dest, keys, NULL, n, NULL);
+}
+#endif
+
 #if defined(SORT_VAR_KEY) || defined(SORT_VAR_DATA) || defined(SORT_UNIFY_WORKSPACE)
 #include "lib/sorter/s-internal.h"
 #else