--- parser3/src/include/pa_hash.h 2015/10/08 15:33:25 1.92 +++ parser3/src/include/pa_hash.h 2016/07/04 17:26:23 1.95 @@ -1,7 +1,7 @@ /** @file Parser: hash class decl. - Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ @@ -17,7 +17,7 @@ #ifndef PA_HASH_H #define PA_HASH_H -#define IDENT_PA_HASH_H "$Id: pa_hash.h,v 1.92 2015/10/08 15:33:25 moko Exp $" +#define IDENT_PA_HASH_H "$Id: pa_hash.h,v 1.95 2016/07/04 17:26:23 moko Exp $" #include "pa_memory.h" #include "pa_types.h" @@ -210,7 +210,6 @@ public: else last=pair->prev; #endif - delete pair; *ref=next; --fpairs_count; return true; @@ -505,7 +504,6 @@ public: else this->last=pair->prev; #endif - delete pair; *ref=next; --this->fpairs_count; return true; @@ -538,6 +536,22 @@ public: return pair->value; return V(0); + } + + /// get associated [value] by the [key], optimized + V get(const char *key) const { + uint code=0; + if(key && *key){ + generic_hash_code(code, key); + } else { + key=0; + } + uint index=code%this->allocated; + for(Pair *pair=this->refs[index]; pair; pair=pair->link) + if(pair->code==code && CORD_cmp(pair->key,(CORD)key)==0) + return pair->value; + + return V(0); } /// put a [value] under the [key] if that [key] existed @returns existed or not