Benkő Pál <benko.pal <at> gmail.com> writes:

> 
> 2013/1/15  <k-ohara5a5a <at> oco.net>:
> > https://codereview.appspot.com/7108043/diff/1/lily/include/audio-
item.hh#newcode90
> > lily/include/audio-item.hh:90: virtual string to_string () const;
> > It seems fine to have the debug-output helper to_string(), but why make
> > it a virtual member function?  Unless the compiler is a lot smarter than
> > me, that would seem to require a pointer to the actual function be
> > stored in every Audio_note object.  Then every user would need extra
> > memory for every note, but would get no benefit.
> 
> no, pointer to the actual function is stored in a per-type (not
> per-object) table,
> the object stores a single pointer to the per-type function table,
> and that pointer is needed anyway for a type with virtual members.
> (btw I thought without checking that to_string is inherited from a
> (very low level) base and now I can't easily check whether it's
> really so - is it?)
> 

Okay.  The class 'Audio_note' is a sub-class of 'Audio_item', which has
virtual functions itself, so the cost of a v-table pointer is already paid.

In any case, one extra word per note is not *too* bad.


_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to