--- parser3/src/include/pa_hash.h 2023/09/26 20:49:07 1.103 +++ parser3/src/include/pa_hash.h 2026/04/25 13:38:46 1.108 @@ -1,23 +1,15 @@ /** @file Parser: hash class decl. - Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) Authors: Konstantin Morshnev , Alexandr Petrosian */ -/* - The prime numbers used from zend_hash.c, - the part of Zend scripting engine library, - Copyrighted (C) 1999-2000 Zend Technologies Ltd. - http://www.zend.com/license/0_92.txt - For more information about Zend please visit http://www.zend.com/ -*/ - #ifndef PA_HASH_H #define PA_HASH_H -#define IDENT_PA_HASH_H "$Id: pa_hash.h,v 1.103 2023/09/26 20:49:07 moko Exp $" +#define IDENT_PA_HASH_H "$Id: pa_hash.h,v 1.108 2026/04/25 13:38:46 moko Exp $" #include "pa_memory.h" #include "pa_types.h" @@ -25,15 +17,12 @@ const int HASH_ALLOCATES_COUNT=29; -/** Zend comment: Generated on an Octa-ALPHA 300MHz CPU & 2.5GB RAM monster - - paf: HPUX ld could not handle static member: unsatisfied symbols -*/ +// nearest primes to 5 * 2^n static uint Hash_allocates[HASH_ALLOCATES_COUNT]={ - 5, 11, 19, 53, 107, 223, 463, 983, 1979, 3907, 7963, - 16229, 32531, 65407, 130987, 262237, 524521, 1048793, - 2097397, 4194103, 8388857, 16777447, 33554201, 67108961, - 134217487, 268435697, 536870683, 1073741621, 2147483399}; + 5, 11, 19, 41, 79, 163, 317, 641, 1279, 2557, 5119, + 10243, 20479, 40961, 81919, 163841, 327673, 655357, + 1310719, 2621447, 5242883, 10485767, 20971529, 41943049, + 83886091, 167772161, 335544323, 671088637, 1342177283}; /// useful generic hash function inline void generic_hash_code(uint& result, char c) { @@ -115,6 +104,9 @@ inline uint hash_code(int self) { #endif +#define HASH_PUT_CSTR(h, cstr, v) \ + { static const String::Body body_##__LINE__(cstr); (h).put(body_##__LINE__, (v)); } + template class HASH: public PA_Object { protected: class Pair; @@ -491,6 +483,10 @@ public: return false; } + bool put(const char *str, V value) { + return put(String::Body(str), value); + } + /// remove the [key] @returns existed or not bool remove(K str) { CORD key=str.get_cord();