data_[thing].pos = Point(x, y);
}
- void add(T const * thing, Dimension const & dim)
- {
- data_[thing].dim = dim;
+ // this returns true if a change is done
+ bool add(T const * thing, Dimension const & dim)
+ {
+ Geometry g;
+ g.dim = dim;
+ auto const result = data_.insert(std::make_pair(thing, g));
+ // did a new entry get inserted?
+ if (result.second)
+ return true;
+ // otherwise, if the existing value is different, update it
+ else if (result.first->second.dim != dim) {
+ result.first->second.dim = dim;
+ return true;
+ }
+ return false;
}
Geometry & geometry(T const * thing)
*/
extrawidths[e.inset] = mi.extrawidth;
- if (!insetCache.has(e.inset) || insetCache.dim(e.inset) != dim) {
- insetCache.add(e.inset, dim);
- changed = true;
- }
+ changed |= insetCache.add(e.inset, dim);
}
// Transform the paragraph into a single row containing all the elements.