Merge branch 'master' of git.sv.gnu.org:/srv/git/lilypond
[lilypond/mpolesky.git] / lily / profile.cc
blob15cd99b06d223fc8bc87187b57e57a4dd61b919a
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "profile.hh"
22 void note_property_access (SCM *table, SCM sym);
24 SCM context_property_lookup_table;
25 SCM grob_property_lookup_table;
26 SCM prob_property_lookup_table;
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}.")
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);
47 void
48 note_property_access (SCM *table, SCM sym)
51 Statistics: which properties are looked up?
53 if (!*table)
54 *table = scm_permanent_object (scm_c_make_hash_table (259));
56 SCM hashhandle = scm_hashq_get_handle (*table, sym);
57 if (hashhandle == SCM_BOOL_F)
59 scm_hashq_set_x (*table, sym, scm_from_int (0));
60 hashhandle = scm_hashq_get_handle (*table, sym);
63 int count = scm_to_int (scm_cdr (hashhandle)) + 1;
64 scm_set_cdr_x (hashhandle, scm_from_int (count));