Make cases simpler, faster, and easier to understand.
[pspp-builds.git] / src / data / scratch-writer.c
index e4d977fbfcfbef9d90588c0e43cac23041f8b386..952860cdc5887e00104be1239f089f3eaf2c71b8 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -46,7 +46,7 @@ struct scratch_writer
     struct casewriter *subwriter;       /* Data output. */
   };
 
-static struct casewriter_class scratch_writer_casewriter_class;
+static const struct casewriter_class scratch_writer_casewriter_class;
 
 /* Opens FH, which must have referent type FH_REF_SCRATCH, and
    returns a scratch_writer for it, or a null pointer on
@@ -99,15 +99,8 @@ scratch_writer_casewriter_write (struct casewriter *w UNUSED, void *writer_,
                                  struct ccase *c)
 {
   struct scratch_writer *writer = writer_;
-  struct ccase tmp;
-  if (writer->compactor)
-    {
-      case_map_execute (writer->compactor, c, &tmp);
-      case_destroy (c);
-    }
-  else
-    case_move (&tmp, c);
-  casewriter_write (writer->subwriter, &tmp);
+  casewriter_write (writer->subwriter,
+                    case_map_execute (writer->compactor, c));
 }
 
 /* Closes WRITER. */
@@ -143,7 +136,7 @@ scratch_writer_casewriter_destroy (struct casewriter *w UNUSED, void *writer_)
   free (writer);
 }
 
-static struct casewriter_class scratch_writer_casewriter_class =
+static const struct casewriter_class scratch_writer_casewriter_class =
   {
     scratch_writer_casewriter_write,
     scratch_writer_casewriter_destroy,