From feb23985504e99693ff87201cd26bf78282506ed Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 20 May 2007 17:13:32 -0300 Subject: [PATCH] page breaking coding style fixes. - rename sys_ -> system_spec_index_ - rename last() -> is_last() - make breaks_ private; add last_break_position() method. --- lily/include/page-breaking.hh | 31 +++++++++++++---------------- lily/optimal-page-breaking.cc | 2 +- lily/page-breaking.cc | 35 ++++++++++++++++++++------------- lily/page-spacing.cc | 2 +- lily/page-turn-page-breaking.cc | 4 ++-- 5 files changed, 39 insertions(+), 35 deletions(-) diff --git a/lily/include/page-breaking.hh b/lily/include/page-breaking.hh index 2bedb23f44..208c1e8b0e 100644 --- a/lily/include/page-breaking.hh +++ b/lily/include/page-breaking.hh @@ -41,40 +41,39 @@ struct System_spec struct Break_position { - /* our index in the all_ list */ - vsize sys_; + vsize system_spec_index_; - /* if sys_ is a score, then we start at the score_brk_'th possible + /* if system_spec_index_ is a score, then we start at the score_brk_'th possible page-break in the score */ vsize score_break_; - /* if sys_ is a score, this points to the broken column */ + /* if system_spec_index_ is a score, this points to the broken column */ Grob *col_; bool score_ender_; Break_position (vsize s=VPOS, vsize brk=VPOS, Grob *g=NULL, bool end=false) { - sys_ = s; + system_spec_index_ = s; score_break_ = brk; col_ = g; score_ender_ = end; } /* - lexicographic in (sys_, score_break_) + lexicographic in (system_spec_index_, score_break_) */ bool operator< (const Break_position &other) { - return (sys_ == VPOS && other.sys_ != VPOS) - || (sys_ < other.sys_) - || (sys_ == other.sys_ && score_break_ < other.score_break_); + return (system_spec_index_ == VPOS && other.system_spec_index_ != VPOS) + || (system_spec_index_ < other.system_spec_index_) + || (system_spec_index_ == other.system_spec_index_ && score_break_ < other.score_break_); } bool operator<= (const Break_position &other) { - return (sys_ == VPOS) - || (sys_ < other.sys_ && other.sys_ != VPOS) - || (sys_ == other.sys_ && score_break_ <= other.score_break_); + return (system_spec_index_ == VPOS) + || (system_spec_index_ < other.system_spec_index_ && other.system_spec_index_ != VPOS) + || (system_spec_index_ == other.system_spec_index_ && score_break_ <= other.score_break_); } }; @@ -97,7 +96,7 @@ public: bool ragged () const; bool ragged_last () const; - bool last () const; + bool is_last () const; Real page_height (int page_number, bool last) const; protected: @@ -135,11 +134,9 @@ protected: SCM breakpoint_property (vsize breakpoint, char const *str); - -protected: - vector breaks_; - + vsize last_break_position () const; private: + vector breaks_; vector chunks_; vector system_specs_; vector line_breaking_; diff --git a/lily/optimal-page-breaking.cc b/lily/optimal-page-breaking.cc index c3d3f03315..4f82c2d1ae 100644 --- a/lily/optimal-page-breaking.cc +++ b/lily/optimal-page-breaking.cc @@ -36,7 +36,7 @@ Optimal_page_breaking::~Optimal_page_breaking () SCM Optimal_page_breaking::solve () { - vsize end = breaks_.size () - 1; + vsize end = last_break_position (); vsize min_sys_count = 0; vsize ideal_sys_count = 0; vsize max_sys_count = max_system_count (0, end); diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index 8243ebc8bd..d84c278a90 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -85,7 +85,7 @@ uncompress_solution (vector const &systems_per_page, vsize Page_breaking::next_system (Break_position const &break_pos) const { - vsize sys = break_pos.sys_; + vsize sys = break_pos.system_spec_index_; if (sys == VPOS) /* beginning of the book */ return 0; @@ -128,14 +128,14 @@ Page_breaking::line_breaker_args (vsize sys, vsize *line_breaker_end) { assert (system_specs_[sys].pscore_); - assert (next_system (start) <= sys && sys <= end.sys_); + assert (next_system (start) <= sys && sys <= end.system_spec_index_); - if (start.sys_ == sys) + if (start.system_spec_index_ == sys) *line_breaker_start = start.score_break_; else *line_breaker_start = 0; - if (end.sys_ == sys) + if (end.system_spec_index_ == sys) *line_breaker_end = end.score_break_; else *line_breaker_end = VPOS; @@ -218,11 +218,11 @@ Page_breaking::breakpoint_property (vsize breakpoint, char const *str) { Break_position const &pos = breaks_[breakpoint]; - if (pos.sys_ == VPOS) + if (pos.system_spec_index_ == VPOS) return SCM_EOL; - if (system_specs_[pos.sys_].pscore_) + if (system_specs_[pos.system_spec_index_].pscore_) return pos.col_->get_property (str); - return system_specs_[pos.sys_].prob_->get_property (str); + return system_specs_[pos.system_spec_index_].prob_->get_property (str); } SCM @@ -649,8 +649,8 @@ Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize fir return Spacing_result (); if (n == 1) ret = space_systems_on_1_page (cached_line_details_, - page_height (first_page_num, last ()), - ragged () || (last () && ragged_last ())); + page_height (first_page_num, is_last ()), + ragged () || (is_last () && ragged_last ())); else if (n == 2) ret = space_systems_on_2_pages (configuration, first_page_num); else @@ -665,7 +665,7 @@ Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize fir Real Page_breaking::blank_page_penalty () const { - SCM penalty_sym = last () ? ly_symbol2scm ("blank-last-page-force") : ly_symbol2scm ("blank-page-force"); + SCM penalty_sym = is_last () ? ly_symbol2scm ("blank-last-page-force") : ly_symbol2scm ("blank-page-force"); return robust_scm2double (book_->paper_->lookup_variable (penalty_sym), 0.0); } @@ -790,9 +790,9 @@ Spacing_result Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_num) { Real page1_height = page_height (first_page_num, false); - Real page2_height = page_height (first_page_num+1, last ()); + Real page2_height = page_height (first_page_num + 1, is_last ()); bool ragged1 = ragged (); - bool ragged2 = ragged () || (last () && ragged_last ()); + bool ragged2 = ragged () || (is_last () && ragged_last ()); /* if there is a forced break, this reduces to 2 1-page problems */ cache_line_details (configuration); @@ -879,7 +879,14 @@ Page_breaking::current_configuration (vsize configuration_index) const return current_configurations_[configuration_index]; } -bool Page_breaking::last () const +bool +Page_breaking::is_last () const +{ + return current_end_breakpoint_ == last_break_position (); +} + +vsize +Page_breaking::last_break_position () const { - return current_end_breakpoint_ == breaks_.size () - 1; + return breaks_.size () - 1; } diff --git a/lily/page-spacing.cc b/lily/page-spacing.cc index d154536956..60e5174c3b 100644 --- a/lily/page-spacing.cc +++ b/lily/page-spacing.cc @@ -74,7 +74,7 @@ Page_spacer::Page_spacer (vector const &lines, vsize first_page_nu breaker_ = breaker; max_page_count_ = 0; ragged_ = breaker->ragged (); - ragged_last_ = breaker->last () && breaker->ragged_last (); + ragged_last_ = breaker->is_last () && breaker->ragged_last (); } Spacing_result diff --git a/lily/page-turn-page-breaking.cc b/lily/page-turn-page-breaking.cc index 782399542c..d17e6a86a3 100644 --- a/lily/page-turn-page-breaking.cc +++ b/lily/page-turn-page-breaking.cc @@ -206,8 +206,8 @@ Page_turn_page_breaking::solve () { state_.clear (); message (_f ("Calculating page and line breaks (%d possible page breaks)...", - (int)breaks_.size () - 1) + " "); - for (vsize i = 0; i + 1 < breaks_.size (); i++) + (int) last_break_position ())); + for (vsize i = 0; i < last_break_position (); i++) { calc_subproblem (i); progress_indication (string ("[") + to_string (i + 1) + "]"); -- 2.39.2