]> git.donarmstrong.com Git - lilypond.git/blob - lily/profile.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / profile.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "profile.hh"
21
22 void note_property_access (SCM *table, SCM sym);
23
24 SCM context_property_lookup_table;
25 SCM grob_property_lookup_table;
26 SCM prob_property_lookup_table;
27
28 LY_DEFINE (ly_property_lookup_stats, "ly:property-lookup-stats",
29            1, 0, 0, (SCM sym),
30            "Return hash table with a property access corresponding to"
31            " @var{sym}.  Choices are @code{prob}, @code{grob}, and"
32            " @code{context}.")
33 {
34   if (sym == ly_symbol2scm ("context"))
35     return context_property_lookup_table ? context_property_lookup_table
36            : scm_c_make_hash_table (1);
37   if (sym == ly_symbol2scm ("prob"))
38     return prob_property_lookup_table ? prob_property_lookup_table
39            : scm_c_make_hash_table (1);
40   if (sym == ly_symbol2scm ("grob"))
41     return grob_property_lookup_table ? grob_property_lookup_table
42            : scm_c_make_hash_table (1);
43   return scm_c_make_hash_table (1);
44 }
45
46 void
47 note_property_access (SCM *table, SCM sym)
48 {
49   /*
50     Statistics: which properties are looked up?
51   */
52   if (!*table)
53     *table = scm_permanent_object (scm_c_make_hash_table (259));
54
55   SCM hashhandle = scm_hashq_get_handle (*table, sym);
56   if (hashhandle == SCM_BOOL_F)
57     {
58       scm_hashq_set_x (*table, sym, scm_from_int (0));
59       hashhandle = scm_hashq_get_handle (*table, sym);
60     }
61
62   int count = scm_to_int (scm_cdr (hashhandle)) + 1;
63   scm_set_cdr_x (hashhandle, scm_from_int (count));
64 }