]> git.donarmstrong.com Git - lilypond.git/blob - lily/symbol-cache.cc
release: 1.3.93
[lilypond.git] / lily / symbol-cache.cc
1 /*   
2   symbol-cache.cc --  implement a cache for literal symbols, eg
3     symbol("foo-bar")
4     
5   
6   source file of the GNU LilyPond music typesetter
7   
8   (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9   
10  */
11
12 #include <map>
13 #include "lily-guile.hh" 
14
15 #if 0
16
17 typedef map<const char*, SCM> Literal_symbol_map;
18 Literal_symbol_map literal_map;
19
20
21 SCM
22 symbol (const char*s)
23 {
24   Literal_symbol_map::const_iterator i = literal_map.find (s);
25   if (i != literal_map.end())
26     return (*i).second;
27
28   SCM sym = gh_symbol2scm ((char*)s);
29   scm_permanent_object (sym);
30   literal_map[s] = sym;
31   return sym;
32 }
33
34
35 /*
36   This is a gory trick to cache the value gh_symbol2scm (), without
37   cluttering up the C code with snarf macros.
38   
39   You should *ONLY* use symbol() for arguments that are literal
40   strings!
41   
42   without (wtk1-fugue2)
43
44         real    0m20.157s
45         user    0m19.800s
46         sys     0m0.140s
47
48   with: (per file.)
49
50         real    0m19.284s
51         user    0m18.630s
52         sys     0m0.190s
53
54
55   global with STL map
56
57         real    0m20.616s
58         user    0m19.360s
59         sys     0m0.080s
60
61   global with binsearch.
62
63
64         real    0m19.352s
65         user    0m18.710s
66         sys     0m0.230s
67   local binsearch
68
69    user 18.8
70
71    local with binsearch, and other optimizations.
72
73    17.7
74 */
75 #endif
76
77