lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What's up with Grob_info::origin_contexts ?


From: David Kastrup
Subject: What's up with Grob_info::origin_contexts ?
Date: Sat, 07 Jul 2018 16:28:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Its definition is:

vector<Context *>
Grob_info::origin_contexts (Translator *end) const
{
  Context *t = origin_trans_->context ();
  vector<Context *> r;
  do
    {
      r.push_back (t);
      t = t->get_parent_context ();
    }
  while (t && t != end->context ());

  return r;
}

>From that there are several deductions:

This array contains all contexts starting at the context where the grob
originated (the one whose make_item got called) and ending _before_ the
context of the named Translator.

Unless both are identical in which case the entire context hierarchy
gets returned.

WTF?

So the returned array will always include at least one context, namely
the result of calling origin_trans_->context () which could equally well
have been gotten calling context ().

All uses I can discern either check whether the returned array is of
non-zero size (which it always is) or then take the first element which
could just be gotten by calling context () instead.

WTF?!?!?

Should we try changing the code such that it works as intended
(presumably returning a 0-size vector when the contexts of the Grob_info
and the given translator disagree which means fixing the unconditional
accesses to [0]) or should we just say "to heck with it" and throw out
all the stuff that apparently worked without ever needing
origin_contexts?

-- 
David Kastrup



reply via email to

[Prev in Thread] Current Thread [Next in Thread]