diff options
author | bjj <bjj> | 2001-01-29 09:08:40 +0000 |
---|---|---|
committer | bjj <bjj> | 2001-01-29 09:08:40 +0000 |
commit | 15bcadfb974f1f02f33910913df897ba57055f23 (patch) | |
tree | 536be21fb259c0cc1c2a1b2482a5ca2719b8a024 | |
parent | 76450e1e889b399a20aba3fe5b53a255d983d042 (diff) | |
download | moo-15bcadfb974f1f02f33910913df897ba57055f23.tar.gz moo-15bcadfb974f1f02f33910913df897ba57055f23.tar.xz moo-15bcadfb974f1f02f33910913df897ba57055f23.zip |
Made STRING_INTERNING optional via options.h.
-rw-r--r-- | options.h | 19 | ||||
-rw-r--r-- | str_intern.c | 28 |
2 files changed, 44 insertions, 3 deletions
@@ -229,7 +229,8 @@ * * NOTE WELL NOTE WELL NOTE WELL NOTE WELL NOTE WELL * - ****************************************************************************** */ + ****************************************************************************** + */ /* #define BYTECODE_REDUCE_REF */ #ifdef BYTECODE_REDUCE_REF @@ -237,6 +238,19 @@ #endif /****************************************************************************** + * The server can merge duplicate strings on load to conserve memory. This + * involves a rather expensive step at startup to dispose of the table used + * to find the duplicates. This should be improved eventually, but you may + * want to trade off faster startup time for increased memory usage. + * + * You might want to turn this off if you see a large delay before the + * INTERN: lines in the log at startup. + ****************************************************************************** + */ + +#define STRING_INTERNING /* */ + +/****************************************************************************** * This package comes with a copy of the implementation of malloc() from GNU * Emacs. This is a very nice and reasonably portable implementation, but some * systems, notably the NeXT machine, won't allow programs to provide their own @@ -336,6 +350,9 @@ /* * $Log$ + * Revision 1.8 2001/01/29 09:08:40 bjj + * Made STRING_INTERNING optional via options.h. + * * Revision 1.7 2000/01/11 02:05:27 nop * More doc tweaking, really warn about BYTECODE_REDUCE_REF. * diff --git a/str_intern.c b/str_intern.c index c051a1a..1a580f5 100644 --- a/str_intern.c +++ b/str_intern.c @@ -5,6 +5,7 @@ #include "str_intern.h" #include "utils.h" +#ifdef STRING_INTERNING struct intern_entry { const char *s; @@ -124,7 +125,8 @@ str_intern_open(int table_size) intern_allocations_saved = 0; } -extern void str_intern_close(void) +void +str_intern_close(void) { int i; struct intern_entry *e, *next; @@ -219,7 +221,7 @@ intern_rehash(int new_size) { /* Make an immutable copy of s. If there's an intern table open, possibly share storage. */ -extern const char * +const char * str_intern(const char *s) { struct intern_entry *e; @@ -255,3 +257,25 @@ str_intern(const char *s) return r; } + +#else /* STRING_INTERNING */ + +const char * +str_intern(const char *s) +{ + return str_dup(s); +} + +void +str_intern_close(void) +{ + ; +} + +void +str_intern_open(int table_size) +{ + ; +} + +#endif /* STRING_INTERNING */ |