dictionary: Make dict_delete_var() much faster in common case.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 25 Jul 2015 15:58:06 +0000 (08:58 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 25 Jul 2015 15:59:30 +0000 (08:59 -0700)
commitac196658f4fd578201d9feee087b02d95643b08e
tree88d43c25b2c8e588e29a40e8da26f863aec09f7f
parentcd62d8a6af433560a534fabb84bb06030bc89b57
dictionary: Make dict_delete_var() much faster in common case.

When a system file is opened, dict_delete_consecutive_vars() deletes lots
of variables if the system file has long string variables.  This was very
slow because of the O(n**2) behavior in dict_delete_var().  The biggest
cost of that O(n**2) behavior was in calling var_clone() on every variable
several times.  Fortunately, the var_clone() call is not necessary in this
case, because the cloned variable is only needed for callbacks, which
aren't set when a dictionary is being read.

This reduced the time to read the dictionary in a particular sample system
file from seconds to milliseconds.
src/data/dictionary.c