X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fspanner.cc;h=f3d13c84f9879a5878a6dc9739528842b94e8205;hb=310229863d7253a87aa28bce502e190023f77dfd;hp=32e0d21201c4bdd2fa8b32870176e0c5d24d6f59;hpb=e18531db1f79fb685fbd16d6a2a67bf4b6c09915;p=lilypond.git diff --git a/lily/spanner.cc b/lily/spanner.cc index 32e0d21201..f3d13c84f9 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1996--2010 Han-Wen Nienhuys + Copyright (C) 1996--2011 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -226,12 +226,14 @@ Spanner::Spanner (SCM s) { break_index_ = 0; spanned_drul_.set (0, 0); + pure_property_cache_ = SCM_UNDEFINED; } Spanner::Spanner (Spanner const &s) : Grob (s) { spanned_drul_.set (0, 0); + pure_property_cache_ = SCM_UNDEFINED; } Real @@ -327,6 +329,8 @@ Spanner::get_broken_left_end_align () const void Spanner::derived_mark () const { + scm_gc_mark (pure_property_cache_); + Direction d = LEFT; do if (spanned_drul_[d]) @@ -454,6 +458,29 @@ Spanner::kill_zero_spanned_time (SCM grob) return SCM_UNSPECIFIED; } +SCM +Spanner::get_cached_pure_property (SCM sym, int start, int end) +{ + // The pure property cache is indexed by (name start . end), where name is + // a symbol, and start and end are numbers referring to the starting and + // ending column ranks of the current line. + if (scm_hash_table_p (pure_property_cache_) == SCM_BOOL_F) + return SCM_UNDEFINED; + + SCM key = scm_cons (sym, scm_cons (scm_from_int (start), scm_from_int (end))); + return scm_hash_ref (pure_property_cache_, key, SCM_UNDEFINED); +} + +void +Spanner::cache_pure_property (SCM sym, int start, int end, SCM val) +{ + if (scm_hash_table_p (pure_property_cache_) == SCM_BOOL_F) + pure_property_cache_ = scm_c_make_hash_table (17); + + SCM key = scm_cons (sym, scm_cons (scm_from_int (start), scm_from_int (end))); + scm_hash_set_x (pure_property_cache_, key, val); +} + ADD_INTERFACE (Spanner, "Some objects are horizontally spanned between objects. For" " example, slurs, beams, ties, etc. These grobs form a subtype"