From: Han-Wen Nienhuys Date: Tue, 19 Jul 2005 10:37:52 +0000 (+0000) Subject: (internal_print): only call X-Git-Tag: release/2.7.1~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f845a58768d96282b307b1482ec5545374ae9995;p=lilypond.git (internal_print): only call glyph-name-procedure if style != default. 3 % speed increase (wtk2-fugue1). --- diff --git a/ChangeLog b/ChangeLog index ea146f8047..7cd9ac0720 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-07-19 Han-Wen Nienhuys + * lily/*-engraver.cc (various): remove double use of + PRECOMPUTED_VIRTUAL function: only use + start_translation_timestep() and stop_translation_timestep(), not + both. + * lily/break-substitution.cc (fast_substitute_grob_array): do fast_substitute_grob_array for all unordered grob_arrays. (substitute_grob): return Grob *. Saves packing/unpacking SCMs. diff --git a/lily/default-bar-line-engraver.cc b/lily/default-bar-line-engraver.cc new file mode 100644 index 0000000000..54c3543d71 --- /dev/null +++ b/lily/default-bar-line-engraver.cc @@ -0,0 +1,84 @@ +/* + timing-engraver.cc -- implement Default_bar_line_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1997--2005 Han-Wen Nienhuys +*/ + +#include "engraver.hh" +#include "context.hh" +#include "multi-measure-rest.hh" +#include "grob.hh" +#include "warn.hh" + + +class Default_bar_line_engraver : public Engraver +{ +protected: + /* Need to know whether we're advancing in grace notes, or not. */ + Moment last_moment_; + + PRECOMPUTED_VIRTUAL void start_translation_timestep (); + PRECOMPUTED_VIRTUAL void stop_translation_timestep (); + +public: + TRANSLATOR_DECLARATIONS (Default_bar_line_engraver); +}; + +#include "translator.icc" + +ADD_TRANSLATOR (Default_bar_line_engraver, + "This engraver determines what kind of automatic bar lines should be produced, " + "and sets @code{whichBar} accordingly. It should be at the same " + "level as @ref{Timing_translator}. ", + /* creats*/ "", + /* accepts */ "", + /* acks */ "", + /* reads */ + "measurePosition automaticBars whichBar barAlways defaultBarType " + "measureLength", + /* write */ "automaticBars"); + + +Default_bar_line_engraver::Default_bar_line_engraver () +{ + last_moment_.main_part_ = Rational (-1); +} + +void +Default_bar_line_engraver::start_translation_timestep () +{ + SCM automatic_bars = get_property ("automaticBars"); + Moment now = now_mom (); + SCM which = get_property ("whichBar"); + + /* Set the first bar of the score? */ + if (!scm_is_string (which)) + which = SCM_EOL; + + Moment mp = measure_position (context ()); + bool start_of_measure = (last_moment_.main_part_ != now.main_part_ + && !mp.main_part_); + + if (!scm_is_string (which) && to_boolean (automatic_bars)) + { + SCM always = get_property ("barAlways"); + + if ((start_of_measure && last_moment_.main_part_ >= Moment (0)) + || to_boolean (always)) + { + /* should this work, or be junked? See input/bugs/no-bars.ly */ + which = get_property ("defaultBarType"); + } + } + + context ()->set_property ("whichBar", which); +} + +void +Default_bar_line_engraver::stop_translation_timestep () +{ + context ()->set_property ("whichBar", SCM_EOL); + last_moment_ = now_mom (); +} diff --git a/lily/fingering-engraver.cc b/lily/fingering-engraver.cc index c2db873a77..245202faa1 100644 --- a/lily/fingering-engraver.cc +++ b/lily/fingering-engraver.cc @@ -16,7 +16,7 @@ class Fingering_engraver : public Engraver { - Link_array reqs_; + Link_array events_; Link_array fingerings_; public: @@ -24,7 +24,6 @@ public: protected: virtual bool try_music (Music *m); PRECOMPUTED_VIRTUAL void stop_translation_timestep (); - PRECOMPUTED_VIRTUAL void start_translation_timestep (); PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); @@ -37,7 +36,7 @@ Fingering_engraver::try_music (Music *m) { if (m->is_mus_type ("fingering-event")) { - reqs_.push (m); + events_.push (m); return true; } return false; @@ -68,10 +67,10 @@ Fingering_engraver::acknowledge_grob (Grob_info inf) void Fingering_engraver::process_music () { - for (int i = reqs_.size (); i--;) + for (int i = events_.size (); i--;) { - SCM dir = reqs_[i]->get_property ("direction"); - make_script (to_dir (dir), reqs_[i], i); + SCM dir = events_[i]->get_property ("direction"); + make_script (to_dir (dir), events_[i], i); } } @@ -131,12 +130,7 @@ Fingering_engraver::stop_translation_timestep () return; fingerings_.clear (); -} - -void -Fingering_engraver::start_translation_timestep () -{ - reqs_.clear (); + events_.clear (); } Fingering_engraver::Fingering_engraver () diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 2ccdef5ec1..c1a973f4a0 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -38,7 +38,6 @@ protected: virtual void finalize (); virtual bool try_music (Music *ev); PRECOMPUTED_VIRTUAL void stop_translation_timestep (); - PRECOMPUTED_VIRTUAL void start_translation_timestep (); PRECOMPUTED_VIRTUAL void process_music (); virtual void acknowledge_grob (Grob_info); }; @@ -134,6 +133,7 @@ Key_engraver::stop_translation_timestep () item_ = 0; context ()->set_property ("lastKeySignature", get_property ("keySignature")); cancellation_ = 0; + key_ev_ = 0; } void @@ -164,12 +164,6 @@ Key_engraver::read_ev (Music const *r) r->get_property ("tonic")); } -void -Key_engraver::start_translation_timestep () -{ - key_ev_ = 0; -} - void Key_engraver::initialize () { diff --git a/lily/note-head.cc b/lily/note-head.cc index a106fd2ab0..b2e451e54c 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -39,13 +39,13 @@ internal_print (Grob *me, String *font_char) } SCM log = scm_int2num (Note_head::get_balltype (me)); - SCM proc = me->get_property ("glyph-name-procedure"); - String suffix = to_string (min (robust_scm2int (me->get_property ("duration-log"), 2), 2)); - if (style != ly_symbol2scm ("default") - && ly_is_procedure (proc)) - suffix = ly_scm2string (scm_call_2 (proc, log, style)); - + if (style != ly_symbol2scm ("default")) + { + SCM proc = me->get_property ("glyph-name-procedure"); + if (ly_is_procedure (proc)) + suffix = ly_scm2string (scm_call_2 (proc, log, style)); + } Font_metric *fm = Font_interface::get_default_font (me); String idx = "noteheads.s" + suffix; diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index e276d303c8..2a90b776ce 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -18,12 +18,11 @@ class Rest_engraver : public Engraver { - Music *rest_req_; + Music *rest_event_; Item *dot_; Grob *rest_; protected: virtual bool try_music (Music *); - PRECOMPUTED_VIRTUAL void stop_translation_timestep (); PRECOMPUTED_VIRTUAL void start_translation_timestep (); PRECOMPUTED_VIRTUAL void process_music (); @@ -36,7 +35,7 @@ public: */ Rest_engraver::Rest_engraver () { - rest_req_ = 0; + rest_event_ = 0; rest_ = 0; dot_ = 0; } @@ -44,29 +43,25 @@ Rest_engraver::Rest_engraver () void Rest_engraver::start_translation_timestep () { - rest_req_ = 0; -} - -void -Rest_engraver::stop_translation_timestep () -{ + rest_event_ = 0; rest_ = 0; dot_ = 0; } + void Rest_engraver::process_music () { - if (rest_req_ && !rest_) + if (rest_event_ && !rest_) { - rest_ = make_item ("Rest", rest_req_->self_scm ()); + rest_ = make_item ("Rest", rest_event_->self_scm ()); - int durlog = unsmob_duration (rest_req_->get_property ("duration"))->duration_log (); + int durlog = unsmob_duration (rest_event_->get_property ("duration"))->duration_log (); rest_->set_property ("duration-log", scm_int2num (durlog)); - int dots = unsmob_duration (rest_req_->get_property ("duration"))->dot_count (); + int dots = unsmob_duration (rest_event_->get_property ("duration"))->dot_count (); if (dots) { @@ -77,7 +72,7 @@ Rest_engraver::process_music () dot_->set_property ("dot-count", scm_int2num (dots)); } - Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch")); + Pitch *p = unsmob_pitch (rest_event_->get_property ("pitch")); /* This is ridiculous -- rests don't have pitch, but we act as if @@ -100,7 +95,7 @@ Rest_engraver::try_music (Music *m) { if (m->is_mus_type ("rest-event")) { - rest_req_ = m; + rest_event_ = m; return true; } return false; diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index b8b36943f3..415f3aa3f5 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -181,8 +181,10 @@ void Separating_line_group_engraver::start_translation_timestep () { if (break_item_) - context ()->unset_property (ly_symbol2scm ("breakableSeparationItem")); - break_item_ = 0; + { + context ()->unset_property (ly_symbol2scm ("breakableSeparationItem")); + break_item_ = 0; + } } void diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index 74d1f52b9f..42f622699e 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -46,7 +46,6 @@ protected: Item *double_percent_; protected: virtual bool try_music (Music *); - PRECOMPUTED_VIRTUAL void stop_translation_timestep (); PRECOMPUTED_VIRTUAL void start_translation_timestep (); PRECOMPUTED_VIRTUAL void process_music (); }; @@ -111,14 +110,10 @@ Slash_repeat_engraver::start_translation_timestep () { repeat_ = 0; } -} - -void -Slash_repeat_engraver::stop_translation_timestep () -{ beat_slash_ = 0; } + #include "translator.icc" ADD_TRANSLATOR (Slash_repeat_engraver, diff --git a/lily/timing-engraver.cc b/lily/timing-engraver.cc deleted file mode 100644 index 54c3543d71..0000000000 --- a/lily/timing-engraver.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* - timing-engraver.cc -- implement Default_bar_line_engraver - - source file of the GNU LilyPond music typesetter - - (c) 1997--2005 Han-Wen Nienhuys -*/ - -#include "engraver.hh" -#include "context.hh" -#include "multi-measure-rest.hh" -#include "grob.hh" -#include "warn.hh" - - -class Default_bar_line_engraver : public Engraver -{ -protected: - /* Need to know whether we're advancing in grace notes, or not. */ - Moment last_moment_; - - PRECOMPUTED_VIRTUAL void start_translation_timestep (); - PRECOMPUTED_VIRTUAL void stop_translation_timestep (); - -public: - TRANSLATOR_DECLARATIONS (Default_bar_line_engraver); -}; - -#include "translator.icc" - -ADD_TRANSLATOR (Default_bar_line_engraver, - "This engraver determines what kind of automatic bar lines should be produced, " - "and sets @code{whichBar} accordingly. It should be at the same " - "level as @ref{Timing_translator}. ", - /* creats*/ "", - /* accepts */ "", - /* acks */ "", - /* reads */ - "measurePosition automaticBars whichBar barAlways defaultBarType " - "measureLength", - /* write */ "automaticBars"); - - -Default_bar_line_engraver::Default_bar_line_engraver () -{ - last_moment_.main_part_ = Rational (-1); -} - -void -Default_bar_line_engraver::start_translation_timestep () -{ - SCM automatic_bars = get_property ("automaticBars"); - Moment now = now_mom (); - SCM which = get_property ("whichBar"); - - /* Set the first bar of the score? */ - if (!scm_is_string (which)) - which = SCM_EOL; - - Moment mp = measure_position (context ()); - bool start_of_measure = (last_moment_.main_part_ != now.main_part_ - && !mp.main_part_); - - if (!scm_is_string (which) && to_boolean (automatic_bars)) - { - SCM always = get_property ("barAlways"); - - if ((start_of_measure && last_moment_.main_part_ >= Moment (0)) - || to_boolean (always)) - { - /* should this work, or be junked? See input/bugs/no-bars.ly */ - which = get_property ("defaultBarType"); - } - } - - context ()->set_property ("whichBar", which); -} - -void -Default_bar_line_engraver::stop_translation_timestep () -{ - context ()->set_property ("whichBar", SCM_EOL); - last_moment_ = now_mom (); -}