"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/include/util/dynamichashtable.h" between
Hoard-3.12.tar.gz and Hoard-3.13.tar.gz

About: The Hoard memory allocator is a drop-in replacement for malloc() that can improve application performance, especially for multithreaded programs running on multiprocessors (hint: newer releases now part of the HeapLayers package).

dynamichashtable.h  (Hoard-3.12):dynamichashtable.h  (Hoard-3.13)
// -*- C++ -*- // -*- C++ -*-
/** /**
* @file dynamichashtable.h * @file dynamichashtable.h
* @brief A thread-safe dynamic hash table based on linear probing. * @brief A thread-safe dynamic hash table based on linear probing.
* @author Emery Berger <http://www.cs.umass.edu/~emery> * @author Emery Berger <http://www.emeryberger.com>
* @note Copyright (C) 2013 by Emery Berger, University of Massachusetts Amher * @note Copyright (C) 2013-2018 by Emery Berger, University of Massachusetts
st. Amherst.
**/ **/
#ifndef DYNAMICHASHTABLE_H #ifndef DYNAMICHASHTABLE_H
#define DYNAMICHASHTABLE_H #define DYNAMICHASHTABLE_H
#include <mutex>
#include <new> #include <new>
#include <stdint.h> #include <stdint.h>
#include "heaplayers.h" #include "heaplayers.h"
#include "checkpoweroftwo.h" #include "checkpoweroftwo.h"
// LOAD_FACTOR_RECIPROCAL is the reciprocal of the maximum load factor // LOAD_FACTOR_RECIPROCAL is the reciprocal of the maximum load factor
// for the hash table. In other words, 1/LOAD_FACTOR_RECIPROCAL is // for the hash table. In other words, 1/LOAD_FACTOR_RECIPROCAL is
// how full the hash table can get. // how full the hash table can get.
// //
skipping to change at line 136 skipping to change at line 137
_entries = allocTable (_size); _entries = allocTable (_size);
#if 0 #if 0
{ {
char buf[255]; char buf[255];
sprintf (buf, "GROWING, was %d/%d, now %d/%d\n", old_elt_count, old_size, _numElements, _size); sprintf (buf, "GROWING, was %d/%d, now %d/%d\n", old_elt_count, old_size, _numElements, _size);
fprintf (stderr, buf); fprintf (stderr, buf);
} }
#endif #endif
if (_entries == NULL) { if (_entries == nullptr) {
// Failed to allocate space for a bigger table. // Failed to allocate space for a bigger table.
// Give up the ghost. // Give up the ghost.
abort(); abort();
} }
// Rehash all the elements. // Rehash all the elements.
unsigned long ct = 0; unsigned long ct = 0;
for (unsigned long i = 0; i < old_size; i++) { for (unsigned long i = 0; i < old_size; i++) {
VALUE_TYPE v; VALUE_TYPE v;
bool isValid = old_entries[i].get (v); bool isValid = old_entries[i].get (v);
skipping to change at line 176 skipping to change at line 177
_entries = allocTable (_size); _entries = allocTable (_size);
#if 0 #if 0
{ {
char buf[255]; char buf[255];
sprintf (buf, "SHRINKING, was %d/%d, now %d/%d\n", old_elt_count, old_size , _numElements, _size); sprintf (buf, "SHRINKING, was %d/%d, now %d/%d\n", old_elt_count, old_size , _numElements, _size);
fprintf (stderr, buf); fprintf (stderr, buf);
} }
#endif #endif
if (_entries == NULL) { if (_entries == nullptr) {
// Failed to allocate space for a bigger table. // Failed to allocate space for a bigger table.
// Give up the ghost. // Give up the ghost.
abort(); abort();
} }
// Rehash all the elements. // Rehash all the elements.
unsigned long ct = 0; unsigned long ct = 0;
for (unsigned long i = 0; i < old_size; i++) { for (unsigned long i = 0; i < old_size; i++) {
VALUE_TYPE v; VALUE_TYPE v;
bool isValid = old_entries[i].get (v); bool isValid = old_entries[i].get (v);
 End of changes. 4 change blocks. 
5 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)