mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Merge remote-tracking branch 'origin/topic/jazoff/datastructures-defer-init'
* origin/topic/jazoff/datastructures-defer-init: Defer initialization of lists and dicts until an item is added.
This commit is contained in:
commit
389fe2bc2a
6 changed files with 59 additions and 44 deletions
|
@ -13,10 +13,6 @@ class IterCookie;
|
|||
declare(PList,DictEntry);
|
||||
declare(PList,IterCookie);
|
||||
|
||||
// Default number of hash buckets in dictionary. The dictionary will
|
||||
// increase the size of the hash table as needed.
|
||||
#define DEFAULT_DICT_SIZE 16
|
||||
|
||||
// Type indicating whether the dictionary should keep track of the order
|
||||
// of insertions.
|
||||
typedef enum { ORDERED, UNORDERED } dict_order;
|
||||
|
@ -30,7 +26,7 @@ extern void generic_delete_func(void*);
|
|||
class Dictionary {
|
||||
public:
|
||||
explicit Dictionary(dict_order ordering = UNORDERED,
|
||||
int initial_size = DEFAULT_DICT_SIZE);
|
||||
int initial_size = 0);
|
||||
virtual ~Dictionary();
|
||||
|
||||
// Member functions for looking up a key, inserting/changing its
|
||||
|
@ -196,7 +192,7 @@ private:
|
|||
class PDict(type) : public Dictionary { \
|
||||
public: \
|
||||
explicit PDict(type)(dict_order ordering = UNORDERED, \
|
||||
int initial_size = DEFAULT_DICT_SIZE) : \
|
||||
int initial_size = 0) : \
|
||||
Dictionary(ordering, initial_size) {} \
|
||||
type* Lookup(const char* key) const \
|
||||
{ \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue