X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdimension-cache.cc;h=69ff282b0a929ec1f3bb13a89795bc16e600e8c8;hb=a6193f6f613e0b2ff519b804d28f99fcd6ec9b92;hp=005499624b6a1b3f0d743dec272a63ec5bc48526;hpb=07e33979c286e1ed73758276fe2c1de6234e9bf4;p=lilypond.git diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index 005499624b..69ff282b0a 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -90,16 +90,16 @@ Dimension_cache::get_offset () const Dimension_cache * Dimension_cache::common_refpoint (Dimension_cache const* s) const { - Link_array my_groups; - for (Dimension_cache const *c = this; c ; c = c->parent_l_) - my_groups.push ((Dimension_cache*)c); - - Dimension_cache const *common=0; - - for (Dimension_cache const * d = s; !common && d; d = d->parent_l_) - common = (Dimension_cache const*)my_groups.find_l (d); - - return (Dimension_cache*) common; + /* + I don't like the quadratic aspect of this code. Maybe this should + be rewritten some time, but the largest chain of parents might be + 10 high or so, so it shouldn't be a real issue. */ + for (Dimension_cache const *c = this; c; c = c->parent_l_) + for (Dimension_cache const * d = s; d; d = d->parent_l_) + if (d == c) + return (Dimension_cache*)d; + + return 0; } Interval