]> git.donarmstrong.com Git - lilypond.git/blob - lily/profile.cc
* lily/grob.cc (Grob): look properties up directly.
[lilypond.git] / lily / profile.cc
1 /*
2   profile.cc -- implement profiling utilities.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "profile.hh"
11
12 void note_property_access (SCM *table, SCM sym);
13
14 SCM context_property_lookup_table;
15 SCM grob_property_lookup_table;
16
17 LY_DEFINE(ly_context_property_lookup_stats, "ly:context-property-lookup-stats",
18           0,0,0, (),
19           "")
20 {
21   return context_property_lookup_table ?  context_property_lookup_table
22     : scm_c_make_hash_table (1);
23 }
24
25
26
27 LY_DEFINE(ly_property_lookup_stats, "ly:grob-property-lookup-stats",
28           0,0,0, (),
29           "")
30 {
31   return grob_property_lookup_table ?  grob_property_lookup_table :
32     scm_c_make_hash_table (1);
33 }
34
35 void
36 note_property_access (SCM *table, SCM sym)
37 {
38   /*
39     Statistics: which properties are looked up? 
40   */
41   if (!*table)
42     *table = scm_permanent_object (scm_c_make_hash_table (259));
43   
44   SCM hashhandle = scm_hashq_get_handle (*table, sym);
45   if (hashhandle == SCM_BOOL_F)
46     {
47       scm_hashq_set_x (*table, sym, scm_from_int (0));
48       hashhandle = scm_hashq_get_handle (*table, sym);
49     }
50
51   int count = scm_to_int (scm_cdr (hashhandle)) + 1;  
52   scm_set_cdr_x (hashhandle, scm_from_int (count));
53 }