/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014, 2015 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
static void
reindex_var (struct dictionary *d, struct vardict_info *vardict)
{
- struct variable *var = vardict->var;
- struct variable *old = var_clone (var);
+ struct variable *old = (d->callbacks && d->callbacks->var_changed
+ ? var_clone (vardict->var)
+ : NULL);
+ struct variable *var = vardict->var;
var_set_vardict (var, vardict);
hmap_insert_fast (&d->name_map, &vardict->name_node,
vardict->name_node.hash);
if ( d->changed ) d->changed (d, d->changed_data);
- if ( d->callbacks && d->callbacks->var_changed )
- d->callbacks->var_changed (d, var_get_dict_index (var), VAR_TRAIT_POSITION, old, d->cb_data);
- var_destroy (old);
+ if (old)
+ {
+ d->callbacks->var_changed (d, var_get_dict_index (var), VAR_TRAIT_POSITION, old, d->cb_data);
+ var_destroy (old);
+ }
}
/* Sets the case_index in V's vardict to CASE_INDEX. */