aboutsummaryrefslogtreecommitdiffstats
path: root/code_gen.c
diff options
context:
space:
mode:
authornop <nop>1998-02-19 07:36:16 +0000
committernop <nop>1998-02-19 07:36:16 +0000
commitfa306b4cdc64de192c8b034fe8167711799a07a2 (patch)
tree65bab613eb810fd4fe95458d08d20bc0315a65c2 /code_gen.c
parenta436cce6d579cd02570b7bca4ea400c9471028f1 (diff)
downloadmoo-cvs-fa306b4cdc64de192c8b034fe8167711799a07a2.tar.gz
moo-cvs-fa306b4cdc64de192c8b034fe8167711799a07a2.tar.xz
moo-cvs-fa306b4cdc64de192c8b034fe8167711799a07a2.zip
Initial string interning during db load.ROGUE.INTERN
Diffstat (limited to 'code_gen.c')
-rw-r--r--code_gen.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/code_gen.c b/code_gen.c
index 5d9a388..54d1a94 100644
--- a/code_gen.c
+++ b/code_gen.c
@@ -23,6 +23,7 @@
#include "program.h"
#include "storage.h"
#include "structures.h"
+#include "str_intern.h"
#include "utils.h"
#include "version.h"
@@ -235,7 +236,16 @@ add_literal(Var v, State * state)
gstate->literals = new_literals;
gstate->max_literals = new_max;
}
- gstate->literals[i = gstate->num_literals++] = var_ref(v);
+ if (v.type == TYPE_STR) {
+ /* intern string if we can */
+ Var nv;
+
+ nv.type = TYPE_STR;
+ nv.v.str = str_intern(v.v.str);
+ gstate->literals[i = gstate->num_literals++] = nv;
+ } else {
+ gstate->literals[i = gstate->num_literals++] = var_ref(v);
+ }
}
add_fixup(FIXUP_LITERAL, i, state);
state->num_literals++;
@@ -1203,9 +1213,12 @@ generate_code(Stmt * stmt, DB_Version version)
char rcsid_code_gen[] = "$Id$";
/* $Log$
-/* Revision 1.3 1997/07/07 03:24:53 nop
-/* Merge UNSAFE_OPTS (r5) after extensive testing.
+/* Revision 1.4 1998/02/19 07:36:16 nop
+/* Initial string interning during db load.
/*
+ * Revision 1.3 1997/07/07 03:24:53 nop
+ * Merge UNSAFE_OPTS (r5) after extensive testing.
+ *
* Revision 1.2.2.1 1997/05/29 15:50:01 nop
* Make sure to clear prev_stacks to avoid referring to uninitialized memory
* later. (Usually multiplied by zero, so only a problem in weird circumstances.)