Make cases simpler, faster, and easier to understand.
authorBen Pfaff <blp@gnu.org>
Wed, 7 Jan 2009 07:17:32 +0000 (23:17 -0800)
committerBen Pfaff <blp@gnu.org>
Wed, 7 Jan 2009 07:17:32 +0000 (23:17 -0800)
commitcc57a28ef6796ae9a64ef80d453f72126956d49d
treeed24028d2ca8c44d91d10d8cdce00bd0b567cf1a
parent9bf1c33953f7feff2a24a06293f6fe96b75cc41a
Make cases simpler, faster, and easier to understand.

Cases (struct ccase) is reference-counted to avoid copying more
data than necessary.  But the existing implementation that uses
separate structures for references to cases (struct ccase) and
the cases themselves (struct case_data) has a number of issues:

   - The semantics of struct ccase are tricky to remember; one
     has to remember to treat struct ccase as essentially a
     pointer type.  I get confused sometimes myself.

     (One of the symptoms of this was the existence of
      the case_nullify and case_is_null functions, which are
      exactly analogous to setting a pointer to null and comparing
      one against null, respectively.)

   - Every reference to data in a case involves two levels of
     indirection, which is one more than actually necessary.

   - The implementation is somewhat complicated.

This commit simplifies things, by dropping a level of indirection.
Now, a case is just a pointer to a struct ccase, which contains
the actual data.  Reference counting is still present, but it is
simplified.  The only thing that must be remembered is that, before
modifying a case that may be shared, it must be passed through
case_unshare() to make a new unshared copy if necessary.
88 files changed:
src/data/case-map.c
src/data/case-map.h
src/data/case-matcher.c
src/data/case-matcher.h
src/data/case-tmpfile.c
src/data/case-tmpfile.h
src/data/case.c
src/data/case.h
src/data/casegrouper.c
src/data/caseinit.c
src/data/casereader-filter.c
src/data/casereader-provider.h
src/data/casereader-translator.c
src/data/casereader.c
src/data/casereader.h
src/data/casewindow.c
src/data/casewindow.h
src/data/casewriter-provider.h
src/data/casewriter-translator.c
src/data/casewriter.c
src/data/casewriter.h
src/data/datasheet.c
src/data/datasheet.h
src/data/gnumeric-reader.c
src/data/lazy-casereader.c
src/data/por-file-reader.c
src/data/por-file-reader.h
src/data/por-file-writer.c
src/data/por-file-writer.h
src/data/procedure.c
src/data/procedure.h
src/data/psql-reader.c
src/data/scratch-reader.h
src/data/scratch-writer.c
src/data/scratch-writer.h
src/data/sparse-cases.c
src/data/subcase.c
src/data/sys-file-reader.c
src/data/sys-file-reader.h
src/data/sys-file-writer.c
src/data/sys-file-writer.h
src/data/transformations.c
src/data/transformations.h
src/language/control/do-if.c
src/language/control/loop.c
src/language/data-io/combine-files.c
src/language/data-io/data-list.c
src/language/data-io/data-parser.c
src/language/data-io/inpt-pgm.c
src/language/data-io/list.q
src/language/data-io/print-space.c
src/language/data-io/print.c
src/language/data-io/save.c
src/language/expressions/evaluate.c
src/language/expressions/operations.def
src/language/stats/aggregate.c
src/language/stats/autorecode.c
src/language/stats/binomial.c
src/language/stats/chisquare.c
src/language/stats/crosstabs.q
src/language/stats/descriptives.c
src/language/stats/examine.q
src/language/stats/flip.c
src/language/stats/frequencies.q
src/language/stats/glm.q
src/language/stats/npar-summary.c
src/language/stats/oneway.q
src/language/stats/rank.q
src/language/stats/regression.q
src/language/stats/reliability.q
src/language/stats/t-test.q
src/language/stats/wilcoxon.c
src/language/tests/datasheet-check.c
src/language/tests/datasheet-check.h
src/language/xforms/compute.c
src/language/xforms/count.c
src/language/xforms/fail.c
src/language/xforms/recode.c
src/language/xforms/sample.c
src/language/xforms/select-if.c
src/math/levene.c
src/math/merge.c
src/math/np.c
src/math/order-stats.c
src/math/sort.c
src/ui/gui/psppire-data-editor.c
src/ui/gui/psppire-data-store.c
src/ui/gui/psppire-data-store.h