X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8875e7ad84fd62fb2f686426e65c5f99a04581dd..d33704ddf2884c8b1cf1178e3cee6d2e1b4004f0:/include/wx/hashmap.h?ds=inline diff --git a/include/wx/hashmap.h b/include/wx/hashmap.h index 0a20a103ea..14e5619e6a 100644 --- a/include/wx/hashmap.h +++ b/include/wx/hashmap.h @@ -34,7 +34,7 @@ #endif #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ - typedef WX_HASH_MAP_NAMESPACE::hash_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME; + typedef WX_HASH_MAP_NAMESPACE::hash_map< KEY_T, VALUE_T, HASH_T, KEY_EQ_T > CLASSNAME #else // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP) @@ -337,23 +337,26 @@ protected: \ /* returns NULL if not found */ \ Node** GetNodePtr( const const_key_type& key ) const \ { \ - Node** node = &m_table[m_hasher( key ) % m_tableBuckets]; \ + size_t bucket = m_hasher( key ) % m_tableBuckets; \ + Node** node = &m_table[bucket]; \ \ while( *node ) \ { \ if( m_equals( m_getKey( (*node)->m_value ), key ) ) \ return node; \ + /* Tell the compiler to not do any strict-aliasing assumptions with a void cast? Can we make such a runtime guarantee? */ \ node = (Node**)&(*node)->m_nxt; \ } \ \ - return 0; \ + return NULL; \ } \ \ /* returns NULL if not found */ \ /* expressing it in terms of GetNodePtr is 5-8% slower :-( */ \ Node* GetNode( const const_key_type& key ) const \ { \ - Node* node = m_table[m_hasher( key ) % m_tableBuckets]; \ + size_t bucket = m_hasher( key ) % m_tableBuckets; \ + Node* node = m_table[bucket]; \ \ while( node ) \ { \ @@ -637,7 +640,10 @@ public: \ \ /* count() == 0 | 1 */ \ size_type count( const const_key_type& key ) \ - { return GetNode( key ) ? 1 : 0; } \ + { \ + /* explicit cast needed to suppress CodeWarrior warnings */ \ + return (size_type)(GetNode( key ) ? 1 : 0); \ + } \ } #endif // !wxUSE_STL || !defined(HAVE_STL_HASH_MAP)