+++ /dev/null
-/*
- symbol-cache.hh -- declare Symbol cacher.
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef SYMBOL_CACHE_HH
-#define SYMBOL_CACHE_HH
-
-#if 1
-
-/*
- A per file cache: for each compilation unit, there is a separate
- cache that maps the address of a string directly to a SCM value
-
- */
-struct Symbol_cache_pair{
- const char * key;
- SCM val ;
-};
-
-static Symbol_cache_pair *private_symbol_cache;
-static Symbol_cache_pair *private_symbol_cache_end;
-
-static SCM
-symbol (const char *ch) __attribute__ ((unused));
-
- SCM
-symbol (const char *ch)
-{
- Symbol_cache_pair * lo = private_symbol_cache;
- Symbol_cache_pair * hi = private_symbol_cache_end -1;
-
- if (lo)
- {
- do
- {
- Symbol_cache_pair * mid = lo + (hi - lo) / 2 ;
- if (mid->key > ch)
- hi = mid;
- else
- lo = mid;
- }
- while ((hi - lo) > 1);
- if (lo->key== ch)
- return lo->val;
- }
-
-
- Symbol_cache_pair * p = private_symbol_cache;
- for (; p < private_symbol_cache_end
- && p->key < ch ; p++)
- ;
-
- int idx = p - private_symbol_cache;
-
- SCM sym = gh_symbol2scm ((char*) ch);
- scm_permanent_object (sym);
-
- int sz = private_symbol_cache_end - private_symbol_cache;
- sz ++ ;
- private_symbol_cache
- = (Symbol_cache_pair*) realloc (private_symbol_cache,
- sizeof (Symbol_cache_pair)* sz);
- private_symbol_cache_end = private_symbol_cache + sz;
- for (p = private_symbol_cache_end -1;
- p != private_symbol_cache + idx; p --)
- *p = * (p - 1);
-
- p->key = ch;
- p->val = sym;
-
- return sym;
-}
-#endif /* SYMBOL_CACHE_HH */
-#endif
+++ /dev/null
-/*
- symbol-cache.cc -- implement a cache for literal symbols, eg
- symbol ("foo-bar")
-
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include <map>
-#include "lily-guile.hh"
-
-#if 0
-
-typedef map<const char*, SCM> Literal_symbol_map;
-Literal_symbol_map literal_map;
-
-
-SCM
-symbol (const char*s)
-{
- Literal_symbol_map::const_iterator i = literal_map.find (s);
- if (i != literal_map.end ())
- return (*i).second;
-
- SCM sym = gh_symbol2scm ((char*)s);
- scm_permanent_object (sym);
- literal_map[s] = sym;
- return sym;
-}
-
-
-/*
- This is a gory trick to cache the value gh_symbol2scm (), without
- cluttering up the C code with snarf macros.
-
- You should *ONLY* use symbol () for arguments that are literal
- strings!
-
- without (wtk1-fugue2)
-
- real 0m20.157s
- user 0m19.800s
- sys 0m0.140s
-
- with: (per file.)
-
- real 0m19.284s
- user 0m18.630s
- sys 0m0.190s
-
-
- global with STL map
-
- real 0m20.616s
- user 0m19.360s
- sys 0m0.080s
-
- global with binsearch.
-
- real 0m19.352s
- user 0m18.710s
- sys 0m0.230s
-
- local binsearch
-
- user 18.8
-
- local with binsearch, and other optimizations.
-
- 17.7
-*/
-#endif
-
-