variable: Skip callback if new format is same as old format. 20120809000508/pspp 20120810000503/pspp
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 9 Aug 2012 06:17:36 +0000 (23:17 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 9 Aug 2012 06:27:43 +0000 (23:27 -0700)
Seems fairly worthwhile.

src/data/variable.c

index cc606cc9e77131911727c1e2df85ee8b217189bc..72d9ade6759cfd33e1ed855e5deac987fd18d3f5 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012 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
@@ -535,9 +535,12 @@ var_get_print_format (const struct variable *v)
 void
 var_set_print_format (struct variable *v, const struct fmt_spec *print)
 {
-  assert (fmt_check_width_compat (print, v->width));
-  v->print = *print;
-  dict_var_changed (v);
+  if (!fmt_equal (&v->print, print))
+    {
+      assert (fmt_check_width_compat (print, v->width));
+      v->print = *print;
+      dict_var_changed (v);
+    }
 }
 
 /* Returns V's write format specification. */
@@ -554,9 +557,12 @@ var_get_write_format (const struct variable *v)
 void
 var_set_write_format (struct variable *v, const struct fmt_spec *write)
 {
-  assert (fmt_check_width_compat (write, v->width));
-  v->write = *write;
-  dict_var_changed (v);
+  if (!fmt_equal (&v->write, write))
+    {
+      assert (fmt_check_width_compat (write, v->width));
+      v->write = *write;
+      dict_var_changed (v);
+    }
 }
 
 /* Sets V's print and write format specifications to FORMAT,