Index: /branches/1.3/xcache.c
===================================================================
--- /branches/1.3/xcache.c	(revision 620)
+++ /branches/1.3/xcache.c	(revision 622)
@@ -556,5 +556,5 @@
 		xc_constinfo_t *ci = &p->constinfos[i];
 		xc_install_constant(xce->name.str.val, &ci->constant,
-				UNISW(0, ci->type), ci->key, ci->key_size TSRMLS_CC);
+				UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC);
 	}
 #endif
@@ -564,5 +564,5 @@
 		xc_funcinfo_t  *fi = &p->funcinfos[i];
 		xc_install_function(xce->name.str.val, &fi->func,
-				UNISW(0, fi->type), fi->key, fi->key_size TSRMLS_CC);
+				UNISW(0, fi->type), fi->key, fi->key_size, fi->h TSRMLS_CC);
 	}
 
@@ -581,5 +581,5 @@
 #endif
 		xc_install_class(xce->name.str.val, &ci->cest, ci->oplineno,
-				UNISW(0, ci->type), ci->key, ci->key_size TSRMLS_CC);
+				UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC);
 	}
 
@@ -590,5 +590,5 @@
 		/*
 		zend_auto_global *auto_global;
-		if (zend_u_hash_find(CG(auto_globals), aginfo->type, aginfo->key, aginfo->key_len+1, (void **) &auto_global)==SUCCESS) {
+		if (zend_u_hash_quick_find(CG(auto_globals), aginfo->type, aginfo->key, aginfo->key_len+1, aginfo->h, (void **) &auto_global)==SUCCESS) {
 			if (auto_global->armed) {
 				auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC);
@@ -1064,4 +1064,5 @@
 		}                                                     \
 		data->key_size   = b->nKeyLength;                     \
+		data->h          = b->h;                              \
 	}                                                         \
 } while(0)
@@ -1096,4 +1097,5 @@
 				}
 				data->key_len = b->nKeyLength - 1;
+				data->h       = b->h;
 			}
 		}
@@ -1266,4 +1268,5 @@
 /* }}} */
 
+#ifdef ZEND_ENGINE_2
 /* {{{ xc_gc_op_array_t */
 typedef struct {
@@ -1277,5 +1280,7 @@
 	gc_op_array.num_args = op_array->num_args;
 	gc_op_array.arg_info = op_array->arg_info;
+#ifdef ZEND_ENGINE_2
 	zend_hash_next_index_insert(&XG(gc_op_arrays), (void *) &gc_op_array, sizeof(gc_op_array), NULL);
+#endif
 }
 /* }}} */
@@ -1295,4 +1300,5 @@
 }
 /* }}} */
+#endif
 
 /* module helper function */
@@ -1501,9 +1507,9 @@
 		zend_hash_destroy(&XG(internal_class_table));
 
-		zend_hash_init_ex(&XG(internal_function_table), 100, NULL, CG(function_table)->pDestructor, 1, 0);
-		zend_hash_init_ex(&XG(internal_class_table),    10,  NULL, CG(class_table)->pDestructor,    1, 0);
-
-		zend_hash_copy(&XG(internal_function_table), CG(function_table), (copy_ctor_func_t) function_add_ref, &tmp_func, sizeof(tmp_func));
-		zend_hash_copy(&XG(internal_class_table), CG(class_table), (copy_ctor_func_t) xc_zend_class_add_ref, &tmp_cest, sizeof(tmp_cest));
+		zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0);
+		zend_hash_init_ex(&XG(internal_class_table),    10,  NULL, NULL, 1, 0);
+
+		zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func));
+		zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &tmp_cest, sizeof(tmp_cest));
 
 		XG(internal_table_copied) = 1;
@@ -1523,5 +1529,7 @@
 	}
 
+#ifdef ZEND_ENGINE_2
 	zend_hash_init(&XG(gc_op_arrays), 32, NULL, xc_gc_op_array, 0);
+#endif
 
 #if PHP_API_VERSION <= 20041225
@@ -1539,5 +1547,7 @@
 {
 	xc_entry_unholds(TSRMLS_C);
+#ifdef ZEND_ENGINE_2
 	zend_hash_destroy(&XG(gc_op_arrays));
+#endif
 	xc_gc_expires_php(TSRMLS_C);
 	xc_gc_expires_var(TSRMLS_C);
Index: /branches/1.3/xcache.h
===================================================================
--- /branches/1.3/xcache.h	(revision 619)
+++ /branches/1.3/xcache.h	(revision 622)
@@ -141,6 +141,12 @@
  	   zend_hash_add(ht, arKey, nKeyLength, pData, nDataSize, pDest)
 
+#	define zend_u_hash_quick_add(ht, type, arKey, nKeyLength, h, pData, nDataSize, pDest) \
+ 	   zend_hash_quick_add(ht, arKey, nKeyLength, h, pData, nDataSize, pDest)
+
 #	define zend_u_hash_update(ht, type, arKey, nKeyLength, pData, nDataSize, pDest) \
  	   zend_hash_update(ht, arKey, nKeyLength, pData, nDataSize, pDest)
+
+#	define zend_u_hash_quick_update(ht, type, arKey, nKeyLength, h, pData, nDataSize, pDest) \
+ 	   zend_hash_quick_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest)
 
 #	define zend_u_hash_find(ht, type, arKey, nKeyLength, pData) \
@@ -223,4 +229,5 @@
 	zstr      key;
 	zend_uint key_size;
+	ulong     h;
 	xc_cest_t cest;
 	int       oplineno;
@@ -235,4 +242,5 @@
 	zstr      key;
 	zend_uint key_size;
+	ulong     h;
 	zend_constant constant;
 } xc_constinfo_t;
@@ -246,4 +254,5 @@
 	zstr      key;
 	zend_uint key_size;
+	ulong     h;
 	zend_function func;
 } xc_funcinfo_t;
@@ -257,4 +266,5 @@
 	zstr       key;
 	zend_uint  key_len;
+	ulong      h;
 } xc_autoglobal_t;
 /* }}} */
Index: /branches/1.3/utils.c
===================================================================
--- /branches/1.3/utils.c	(revision 617)
+++ /branches/1.3/utils.c	(revision 622)
@@ -425,5 +425,5 @@
 
 #ifdef HAVE_XCACHE_CONSTANT
-void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, zstr key, uint len TSRMLS_DC) /* {{{ */
+void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC) /* {{{ */
 {
 	if (zend_u_hash_add(EG(zend_constants), type, key, len,
@@ -445,5 +445,5 @@
 /* }}} */
 #endif
-void xc_install_function(char *filename, zend_function *func, zend_uchar type, zstr key, uint len TSRMLS_DC) /* {{{ */
+void xc_install_function(char *filename, zend_function *func, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC) /* {{{ */
 {
 	zend_bool istmpkey;
@@ -475,5 +475,5 @@
 }
 /* }}} */
-ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, int oplineno, zend_uchar type, zstr key, uint len TSRMLS_DC) /* {{{ */
+ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, int oplineno, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC) /* {{{ */
 {
 	zend_bool istmpkey;
@@ -487,5 +487,5 @@
 #endif
 	if (istmpkey) {
-		zend_u_hash_update(CG(class_table), type, key, len,
+		zend_u_hash_quick_update(CG(class_table), type, key, len, h,
 					cest, sizeof(xc_cest_t),
 					ZESW(&stored_ce_ptr, NULL)
@@ -495,5 +495,5 @@
 		}
 	}
-	else if (zend_u_hash_add(CG(class_table), type, key, len,
+	else if (zend_u_hash_quick_add(CG(class_table), type, key, len, h,
 				cest, sizeof(xc_cest_t),
 				ZESW(&stored_ce_ptr, NULL)
@@ -541,13 +541,4 @@
 #endif
 
-void xc_zend_class_add_ref(zend_class_entry ZESW(*ce, **ce))
-{
-#ifdef ZEND_ENGINE_2
-	(*ce)->refcount++;
-#else
-	(*ce->refcount)++;
-#endif
-}
-
 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */
 {
@@ -592,5 +583,5 @@
 	{
 		zend_function tmp_func;
-		zend_hash_copy(&TG(function_table), &XG(internal_function_table), (copy_ctor_func_t) function_add_ref, (void *) &tmp_func, sizeof(tmp_func));
+		zend_hash_copy(&TG(function_table), &XG(internal_function_table), NULL, (void *) &tmp_func, sizeof(tmp_func));
 	}
 	TG(internal_function_tail) = TG(function_table).pListTail;
@@ -601,5 +592,5 @@
 	{
 		xc_cest_t tmp_cest;
-		zend_hash_copy(&TG(class_table), &XG(internal_class_table), (copy_ctor_func_t) xc_zend_class_add_ref, (void *) &tmp_cest, sizeof(tmp_cest));
+		zend_hash_copy(&TG(class_table), &XG(internal_class_table), NULL, (void *) &tmp_cest, sizeof(tmp_cest));
 	}
 #endif
@@ -645,5 +636,5 @@
 		zend_constant *c = (zend_constant*) b->pData;
 		xc_install_constant(sandbox->filename, c,
-				BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), b->nKeyLength TSRMLS_CC);
+				BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), b->nKeyLength, b->h TSRMLS_CC);
 		b = b->pListNext;
 	}
@@ -655,5 +646,5 @@
 		zend_function *func = (zend_function*) b->pData;
 		xc_install_function(sandbox->filename, func,
-				BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), b->nKeyLength TSRMLS_CC);
+				BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), b->nKeyLength, b->h TSRMLS_CC);
 		b = b->pListNext;
 	}
@@ -663,5 +654,5 @@
 	while (b != NULL) {
 		xc_install_class(sandbox->filename, (xc_cest_t*) b->pData, -1,
-				BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), b->nKeyLength TSRMLS_CC);
+				BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), b->nKeyLength, b->h TSRMLS_CC);
 		b = b->pListNext;
 	}
Index: /branches/1.3/utils.h
===================================================================
--- /branches/1.3/utils.h	(revision 600)
+++ /branches/1.3/utils.h	(revision 622)
@@ -72,8 +72,8 @@
 /* installer */
 #ifdef HAVE_XCACHE_CONSTANT
-void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, zstr key, uint len TSRMLS_DC);
+void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC);
 #endif
-void xc_install_function(char *filename, zend_function *func, zend_uchar type, zstr key, uint len TSRMLS_DC);
-ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, int oplineno, zend_uchar type, zstr key, uint len TSRMLS_DC);
+void xc_install_function(char *filename, zend_function *func, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC);
+ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, int oplineno, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC);
 
 /* sandbox */
Index: /branches/1.3/const_string.c
===================================================================
--- /branches/1.3/const_string.c	(revision 618)
+++ /branches/1.3/const_string.c	(revision 622)
@@ -70,4 +70,6 @@
 #elif defined(ZEND_ENGINE_2)
 #	include "const_string_opcodes_php5.0.h"
+#else
+#	include "const_string_opcodes_php4.x.h"
 #endif
 
Index: /branches/1.3/disassembler.c
===================================================================
--- /branches/1.3/disassembler.c	(revision 394)
+++ /branches/1.3/disassembler.c	(revision 622)
@@ -66,5 +66,5 @@
 			}
 		}
-		add_u_assoc_zval_ex(list, BUCKET_KEY_TYPE(b), buf, b->nKeyLength, zv);
+		add_u_assoc_zval_ex(list, BUCKET_KEY_TYPE(b), ZSTR(buf), b->nKeyLength, zv);
 	}
 	efree(buf);
Index: /branches/1.3/processor/hashtable.m4
===================================================================
--- /branches/1.3/processor/hashtable.m4	(revision 394)
+++ /branches/1.3/processor/hashtable.m4	(revision 622)
@@ -60,5 +60,5 @@
 					}
 				}
-				add_u_assoc_zval_ex(dst, BUCKET_KEY_TYPE(b), buf, keysize, zv);
+				add_u_assoc_zval_ex(dst, BUCKET_KEY_TYPE(b), ZSTR(buf), keysize, zv);
 			}
 			')
Index: /branches/1.3/processor/processor.m4
===================================================================
--- /branches/1.3/processor/processor.m4	(revision 621)
+++ /branches/1.3/processor/processor.m4	(revision 622)
@@ -57,7 +57,5 @@
 DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , `
 #ifdef ZEND_ENGINE_2_2
-#ifndef IS_UNICODE
 	DISPATCH(int, start)
-#endif
 #endif
 	DISPATCH(int, cont)
@@ -243,5 +241,5 @@
 	pushdef(`emalloc', `malloc($1)')
 	pushdef(`ecalloc', `calloc($1, $2)')
-	PROC_ZSTRING_L(, name, name_len)
+	PROC_ZSTRING_N(, name, name_len)
 	popdef(`ecalloc')
 	popdef(`emalloc')
@@ -283,5 +281,5 @@
 #endif
 	dnl isnt in php6 yet
-#if defined(ZEND_ENGINE_2_2) && !defined(IS_UNICODE)
+#if defined(ZEND_ENGINE_2_2)
 	PROC_CLASS_ENTRY_P(ce)
 #endif
@@ -511,6 +509,8 @@
 		/* deep */
 		STRUCT_P(HashTable, static_variables, HashTable_zval_ptr)
+#ifdef ZEND_ENGINE_2
 		STRUCT_ARRAY_I(num_args, zend_arg_info, arg_info)
 		xc_gc_add_op_array(dst TSRMLS_CC);
+#endif
 		define(`SKIPASSERT_ONCE')
 	}
@@ -646,5 +646,5 @@
 				 && zend_u_hash_find(&(processor->active_class_entry_dst->parent->function_table),
 						UG(unicode) ? IS_UNICODE : IS_STRING,
-						src->function_name, xc_zstrlen(UG(unicode), src->function_name) + 1,
+						src->function_name, xc_zstrlen(UG(unicode) ? IS_UNICODE : IS_STRING, src->function_name) + 1,
 						(void **) &parent) == SUCCESS) {
 					/* see do_inherit_method_check() */
@@ -670,17 +670,12 @@
 #endif
 
-	IFRESTORE(`
-#ifdef ZEND_ENGINE_2
+#ifdef ZEND_ENGINE_2
+	PROC_CLASS_ENTRY_P(scope)
+	IFCOPY(`
 		if (src->scope) {
-			dst->scope = xc_get_class(processor, (zend_ulong) src->scope);
-			xc_fix_method(processor, dst);
-		}
-		DONE(scope)
-#endif
-	', `
-#ifdef ZEND_ENGINE_2
-		PROC_CLASS_ENTRY_P(scope)
-#endif
-	')
+			xc_fix_method(processor, dst TSRMLS_CC);
+		}
+	')
+#endif
 
 	IFRESTORE(`
@@ -701,4 +696,5 @@
 		PROC_ZSTRING_N(type, key, key_size)
 	')
+	DISPATCH(ulong, h)
 	STRUCT(zend_constant, constant)
 ')
@@ -713,4 +709,5 @@
 		PROC_ZSTRING_N(type, key, key_size)
 	')
+	DISPATCH(ulong, h)
 	STRUCT(zend_function, func)
 ')
@@ -724,4 +721,5 @@
 		PROC_ZSTRING_N(type, key, key_size)
 	')
+	DISPATCH(ulong, h)
 #ifdef ZEND_ENGINE_2
 	STRUCT_P(zend_class_entry, cest)
@@ -741,4 +739,5 @@
 		PROC_ZSTRING_L(type, key, key_len)
 	')
+	DISPATCH(ulong, h)
 ')
 dnl }}}
Index: /branches/1.3/processor/head.m4
===================================================================
--- /branches/1.3/processor/head.m4	(revision 494)
+++ /branches/1.3/processor/head.m4	(revision 622)
@@ -114,10 +114,5 @@
 static inline int xc_zstrlen_uchar(zstr s)
 {
-	int i;
-	UChar *p = ZSTR_U(s);
-	for (i = 0; *p; i ++, p++) {
-		/* empty */
-	}
-	return i;
+	return u_strlen(ZSTR_U(s));
 }
 /* }}} */
@@ -215,8 +210,9 @@
 #ifdef ZEND_ENGINE_2
 /* fix method on store */
-static void xc_fix_method(xc_processor_t *processor, zend_op_array *dst) /* {{{ */
+static void xc_fix_method(xc_processor_t *processor, zend_op_array *dst TSRMLS_DC) /* {{{ */
 {
 	zend_function *zf = (zend_function *) dst;
 	zend_class_entry *ce = processor->active_class_entry_dst;
+	const zend_class_entry *srcce = processor->active_class_entry_src;
 
 	/* Fixing up the default functions for objects here since
@@ -239,14 +235,5 @@
 	}
 	else {
-dnl FIXME: handle common.function_name here
-#define SET_IF_SAME_NAME(member) \
-		do { \
-			if (!strcasecmp(ZSTR_S(zf->common.function_name), #member)) { \
-				ce->member = zf; \
-			} \
-		} \
-		while(0)
-		/* if(ce->member && !strcmp(zf->common.function_name, ce->member->common.function_name)) { \ */
-
+	pushdef(`SET_IF_SAME_NAMEs', `
 		SET_IF_SAME_NAME(__get);
 		SET_IF_SAME_NAME(__set);
@@ -262,6 +249,35 @@
 		SET_IF_SAME_NAME(__tostring);
 #endif
-
+	')
+#ifdef IS_UNICODE
+		if (UG(unicode)) {
+#define SET_IF_SAME_NAME(member) \
+			do { \
+				if (srcce->member && u_strcmp(ZSTR_U(zf->common.function_name), ZSTR_U(srcce->member->common.function_name)) == 0) { \
+					ce->member = zf; \
+				} \
+			} \
+			while(0)
+
+			SET_IF_SAME_NAMEs()
 #undef SET_IF_SAME_NAME
+		}
+		else
+#endif
+		do {
+#define SET_IF_SAME_NAME(member) \
+			do { \
+				if (srcce->member && strcmp(ZSTR_S(zf->common.function_name), ZSTR_S(srcce->member->common.function_name)) == 0) { \
+					ce->member = zf; \
+				} \
+			} \
+			while(0)
+
+			SET_IF_SAME_NAMEs()
+#undef SET_IF_SAME_NAME
+		} while (0);
+
+	popdef(`SET_IF_SAME_NAMEs')
+
 	}
 }
Index: /branches/1.3/processor/main.m4
===================================================================
--- /branches/1.3/processor/main.m4	(revision 593)
+++ /branches/1.3/processor/main.m4	(revision 622)
@@ -111,5 +111,5 @@
 		IFSTORE(`$1 = (zend_class_entry *) xc_get_class_num(processor, $2);')
 		IFRESTORE(`$1 = xc_get_class(processor, (zend_ulong) $2);')
-		IFDASM(`add_assoc_stringl_ex(dst, ZEND_STRS("$3"), $2->name, strlen($2->name), 1);')
+		IFDASM(`add_assoc_unicodel_ex(dst, ZEND_STRS("$3"), ZSTR_U($2->name), $2->name_length, 1);')
 	}
 	else {
Index: /branches/1.3/processor/string.m4
===================================================================
--- /branches/1.3/processor/string.m4	(revision 394)
+++ /branches/1.3/processor/string.m4	(revision 622)
@@ -39,5 +39,5 @@
 
 				INIT_ZVAL(zv);
-				ZVAL_UNICODEL(&zv, (UChar *) ($2), $3 - 1, 1);
+				ZVAL_UNICODEL(&zv, ZSTR_U($2), $3 - 1, 1);
 				zend_make_printable_zval(&zv, &reszv, &usecopy);
 				fprintf(stderr, "string:%s:\t\"", "$1");
@@ -64,9 +64,14 @@
 		FIXPOINTER_EX(`PTRTYPE', DSTPTR)
 		IFDASM(`
-				ifelse(STRTYPE,zstr_uchar, `
-					add_assoc_unicodel_ex(dst, ZEND_STRS("$4"), $2, $3-1, 1);
-					', ` dnl else
-					add_assoc_stringl_ex(dst, ZEND_STRS("$4"), $2, $3-1, 1);')
+			ifelse(STRTYPE,zstr_uchar, `
+				add_assoc_unicodel_ex(dst, ZEND_STRS("$4"), ZSTR_U($2), $3-1, 1);
+				', ` dnl else
+				ifelse(STRTYPE,zstr_char, `
+					add_assoc_stringl_ex(dst, ZEND_STRS("$4"), ZSTR_S($2), $3-1, 1);
+					', `
+					add_assoc_stringl_ex(dst, ZEND_STRS("$4"), $2, $3-1, 1);
 				')
+			')
+		')
 	}
 	popdef(`DSTPTR')
Index: /branches/1.3/xcache-test.ini
===================================================================
--- /branches/1.3/xcache-test.ini	(revision 234)
+++ /branches/1.3/xcache-test.ini	(revision 622)
@@ -1,3 +1,4 @@
 auto_globals_jit = Off
+memory_limit = 256M
 
 [xcache]
Index: /branches/1.3/xcache_globals.h
===================================================================
--- /branches/1.3/xcache_globals.h	(revision 619)
+++ /branches/1.3/xcache_globals.h	(revision 622)
@@ -18,5 +18,7 @@
 	zend_bool auth_enabled;
 
+#ifdef ZEND_ENGINE_2
 	HashTable gc_op_arrays;
+#endif
 
 	HashTable internal_function_table;
