Ignore:
Timestamp:
07/21/15 13:31:23 (10 years ago)
Author:
epyon
Message:
  • hash storage type
  • string hash storage type
  • several minor fixes
  • more cleanups needed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_state.cc

    r426 r431  
    184184}
    185185
    186 uint64 nv::lua::table_guard::get_string_hash_64( string_view element, uint64 defval /*= 0 */ )
     186shash64 nv::lua::table_guard::get_string_hash_64( string_view element, uint64 defval /*= 0 */ )
    187187{
    188188        lua_getfield( m_state, -1, element.data() );
     
    196196        }
    197197        lua_pop( m_state, 1 );
    198         return result;
     198        return shash64( result );
     199}
     200
     201shash64 nv::lua::table_guard::get_string( string_view element, string_table& table, uint64 defval /*= 0 */ )
     202{
     203        lua_getfield( m_state, -1, element.data() );
     204        size_t l = 0;
     205        const char* str = nullptr;
     206        uint64 result = defval;
     207        if ( lua_type( m_state, -1 ) == LUA_TSTRING )
     208        {
     209                str = lua_tolstring( m_state, -1, &l );
     210                result = table.insert( string_view( str, l ) ).value();
     211        }
     212        lua_pop( m_state, 1 );
     213        return shash64( result );
    199214}
    200215
Note: See TracChangeset for help on using the changeset viewer.