]> granicus.if.org Git - php/commitdiff
rename REAL_KEY_SIZE() to USTR_BYTES() and move to zend_unicode.h
authorAntony Dovgal <tony2001@php.net>
Fri, 20 Oct 2006 10:33:31 +0000 (10:33 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 20 Oct 2006 10:33:31 +0000 (10:33 +0000)
this macro is going to be actively used in Unicode version of OCI8 (and other extensions, probably)

Zend/zend_hash.c
Zend/zend_hash.h
Zend/zend_unicode.h

index e471b1aa70fef623b5cf4cf2bd779f8b1e97b94a..2540bd663df14fe9850709260185184c4a42d545 100644 (file)
@@ -246,7 +246,7 @@ ZEND_API int _zend_u_hash_add_or_update(HashTable *ht, zend_uchar type, zstr arK
        }
 
        UNICODE_KEY(ht, type, arKey, nKeyLength, tmp);
-       realKeyLength = REAL_KEY_SIZE(type, nKeyLength);
+       realKeyLength = USTR_BYTES(type, nKeyLength);
 
        h = zend_u_inline_hash_func(type, arKey, nKeyLength);
        nIndex = h & ht->nTableMask;
@@ -399,7 +399,7 @@ ZEND_API int _zend_u_hash_quick_add_or_update(HashTable *ht, zend_uchar type, zs
                UNICODE_KEY(ht, type, arKey, nKeyLength, tmp);
                h = zend_u_inline_hash_func(IS_UNICODE, arKey, nKeyLength);
        }
-       realKeyLength = REAL_KEY_SIZE(type, nKeyLength);
+       realKeyLength = USTR_BYTES(type, nKeyLength);
 
        nIndex = h & ht->nTableMask;
 
@@ -606,7 +606,7 @@ ZEND_API int zend_u_hash_del_key_or_index(HashTable *ht, zend_uchar type, zstr a
 
        if (flag == HASH_DEL_KEY) {
                UNICODE_KEY(ht, type, arKey, nKeyLength, tmp);
-               realKeyLength = REAL_KEY_SIZE(type, nKeyLength);
+               realKeyLength = USTR_BYTES(type, nKeyLength);
                h = zend_u_inline_hash_func(type, arKey, nKeyLength);
        }
        nIndex = h & ht->nTableMask;
@@ -1081,7 +1081,7 @@ ZEND_API int zend_u_hash_find(HashTable *ht, zend_uchar type, zstr arKey, uint n
        IS_CONSISTENT(ht);
 
        UNICODE_KEY(ht, type, arKey, nKeyLength, tmp);
-       realKeyLength = REAL_KEY_SIZE(type, nKeyLength);
+       realKeyLength = USTR_BYTES(type, nKeyLength);
 
        h = zend_u_inline_hash_func(type, arKey, nKeyLength);
        nIndex = h & ht->nTableMask;
@@ -1189,7 +1189,7 @@ ZEND_API int zend_u_hash_quick_find(HashTable *ht, zend_uchar type, zstr arKey,
                UNICODE_KEY(ht, type, arKey, nKeyLength, tmp);
                h = zend_u_inline_hash_func(IS_UNICODE, arKey, nKeyLength);
        }
-       realKeyLength = REAL_KEY_SIZE(type, nKeyLength);
+       realKeyLength = USTR_BYTES(type, nKeyLength);
 
        nIndex = h & ht->nTableMask;
 
@@ -1225,7 +1225,7 @@ ZEND_API int zend_u_hash_exists(HashTable *ht, zend_uchar type, zstr arKey, uint
        IS_CONSISTENT(ht);
 
        UNICODE_KEY(ht, type, arKey, nKeyLength, tmp);
-       realKeyLength = REAL_KEY_SIZE(type, nKeyLength);
+       realKeyLength = USTR_BYTES(type, nKeyLength);
 
        h = zend_u_inline_hash_func(type, arKey, nKeyLength);
        nIndex = h & ht->nTableMask;
@@ -1332,7 +1332,7 @@ ZEND_API int zend_u_hash_quick_exists(HashTable *ht, zend_uchar type, zstr arKey
                UNICODE_KEY(ht, type, arKey, nKeyLength, tmp);
                h = zend_u_inline_hash_func(type, arKey, nKeyLength);
        }
-       realKeyLength = REAL_KEY_SIZE(type, nKeyLength);
+       realKeyLength = USTR_BYTES(type, nKeyLength);
 
        nIndex = h & ht->nTableMask;
 
@@ -1748,7 +1748,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
                                        result = p1->nKeyLength - p2->nKeyLength;
                                }
                                if (result==0) {
-                                       result = memcmp(p1->key.arKey.s, p2->key.arKey.s, REAL_KEY_SIZE(p1->key.type, p1->nKeyLength));
+                                       result = memcmp(p1->key.arKey.s, p2->key.arKey.s, USTR_BYTES(p1->key.type, p1->nKeyLength));
                                }
                                if (result!=0) {
                                        HASH_UNPROTECT_RECURSION(ht1);
index 2245ff5574097fc4699b6c0deaf11ba84903eb86..e572bdb21d1507de2cf76b3d10335295c9517850 100644 (file)
@@ -37,8 +37,6 @@
 #define HASH_DEL_KEY 0
 #define HASH_DEL_INDEX 1
 
-#define REAL_KEY_SIZE(type, nKeyLength) \
-       ((type == IS_UNICODE)?UBYTES(nKeyLength):nKeyLength)
 
 
 typedef ulong (*hash_func_t)(char *arKey, uint nKeyLength);
@@ -336,7 +334,7 @@ EMPTY_SWITCH_DEFAULT_CASE()
 }
 
 #define zend_u_inline_hash_func(type, arKey, nKeyLength) \
-       zend_inline_hash_func(arKey.s, REAL_KEY_SIZE(type, nKeyLength))
+       zend_inline_hash_func(arKey.s, USTR_BYTES(type, nKeyLength))
 
 ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength);
 ZEND_API ulong zend_u_hash_func(zend_uchar type, zstr arKey, uint nKeyLength);
index f9569293421cee1da6b62e4d5149920664fc587c..c77e972382a0eb6f77a8c3333a995a58c01b6fcb 100644 (file)
@@ -136,6 +136,9 @@ static inline int zend_codepoint_to_uchar(UChar32 codepoint, UChar *buf)
 #define USTR_LEN(str) (UG(unicode)?u_strlen((str).u):strlen((str).s))
 #define USTR_VAL(str) (UG(unicode)?(str).u:(str).s)
 
+#define USTR_BYTES(__type, __length) \
+       ((__type == IS_UNICODE)?UBYTES(__length):__length)
+
 #define USTR_MAKE(cs) zend_ascii_to_unicode(cs, sizeof(cs) ZEND_FILE_LINE_CC)
 #define USTR_MAKE_REL(cs) zend_ascii_to_unicode(cs, sizeof(cs) ZEND_FILE_LINE_RELAY_CC)
 static inline UChar* zend_ascii_to_unicode(const char *cs, size_t cs_size ZEND_FILE_LINE_DC)