From: Ben Pfaff Date: Sat, 28 Sep 2013 23:03:32 +0000 (-0700) Subject: variable: Only notify variable width change if it really did change. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61bf4a044aafdca09f4b2c363b6636d44e93d215;p=pspp variable: Only notify variable width change if it really did change. This code was notifying a width change every time, even if the width did not really change, which is wasteful. This had a side effect of revealing a bug in the GUI code which caused an assertion failure. The bug still remains in the GUI code, though it is now slightly harder to trigger, and will be fixed separately in an upcoming commit. --- diff --git a/src/data/variable.c b/src/data/variable.c index 9f21b1497b..72dd2d8ef6 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -285,8 +285,11 @@ var_set_width_and_formats (struct variable *v, int new_width, if (fmt_resize (&v->write, new_width)) traits |= VAR_TRAIT_WRITE_FORMAT; - v->width = new_width; - traits |= VAR_TRAIT_WIDTH; + if (v->width != new_width) + { + v->width = new_width; + traits |= VAR_TRAIT_WIDTH; + } if (print) { @@ -300,7 +303,8 @@ var_set_width_and_formats (struct variable *v, int new_width, traits |= VAR_TRAIT_WRITE_FORMAT; } - dict_var_changed (v, traits, ov); + if (traits != 0) + dict_var_changed (v, traits, ov); } /* Changes the width of V to NEW_WIDTH.