X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCoordCache.h;h=f26b6b22dd523791b9c73536f4488356d2649653;hb=0e4ca9aa88eb7b9351bb563dcd2df59c15744aa5;hp=2780fc32138b1088833a8bd143aec392fe818fe9;hpb=e09158efee92c6a57f5228af35f1cf8e0eeb07d8;p=lyx.git diff --git a/src/CoordCache.h b/src/CoordCache.h index 2780fc3213..f26b6b22dd 100644 --- a/src/CoordCache.h +++ b/src/CoordCache.h @@ -26,7 +26,7 @@ class MathData; void lyxbreaker(void const * data, const char * hint, int size); struct Geometry { - Point pos; + Point pos = {-10000, -10000 }; Dimension dim; bool covers(int x, int y) const @@ -75,14 +75,18 @@ public: void add(T const * thing, Dimension const & dim) { - if (!has(thing)) - data_[thing].pos = Point(-10000, -10000); data_[thing].dim = dim; } + Geometry & geometry(T const * thing) + { + checkDim(thing, "geometry"); + return data_.find(thing)->second; + } + Geometry const & geometry(T const * thing) const { - check(thing, "geometry"); + checkDim(thing, "geometry"); return data_.find(thing)->second; } @@ -141,6 +145,7 @@ public: private: friend class CoordCache; +#ifdef ENABLE_ASSERTIONS void checkDim(T const * thing, char const * hint) const { if (!hasDim(thing)) @@ -152,6 +157,11 @@ private: if (!has(thing)) lyxbreaker(thing, hint, data_.size()); } +#else + void checkDim(T const *, char const * const ) const {} + + void check(T const *, char const *) const {} +#endif typedef std::unordered_map cache_type; cache_type data_;