#26 Variables implementation on hash_map

closed-rejected
nobody
None
5
2005-02-11
2004-08-21
Rafał Rzepecki
No

A Variables implementation based on GNU STL's
hash_map.

Discussion

  • Variables.cpp

     
    Attachments
  • Variables.h

     
    Attachments
  • Logged In: YES
    user_id=23042

    Some comments

    * sometimes the key passed to the class is copied, and
    sometimes it isn't copied. In the best case this leads to
    memory leaks, in the worst case to memory corruption. IMHO,
    it is a bad idea to store pointers in the Variables class to
    strings not created by the class.

    * same for the values in the case the type is string.

    * there are currently two hash_map lookups for every
    operation. One count and one actual dereference. It's
    probably faster to do a find() into an iterator, check if
    the iterator is different from end() and dereference the
    iterator if so.

    * strnlen at the top doesn't appear to be used.

     
  • Laszlo Toth
    Laszlo Toth
    2005-02-11

    • status: open --> closed-rejected
     
  • Laszlo Toth
    Laszlo Toth
    2005-02-11

    Logged In: YES
    user_id=885460

    I have found that stl hashmap is not really portable to msvc.
    Instead of relying on compiler supplied libraries, i've made
    some slight tweaks on the current implementation.

    An alternate implementation must have the following features:
    1. portable to msvc/gcc (compiled on win32/linux/bsd/unix)
    2. customisable hashmap size
    3. small footprint on memory
    4. memory allocation is optimized