Changeset 421


Ignore:
Timestamp:
07/16/15 11:59:00 (10 years ago)
Author:
epyon
Message:
  • move ops for data_channel_set
  • string_table works on string_views, stores hashes
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/interface/data_channel.hh

    r419 r421  
    8686                typedef const raw_data_channel* const_iterator;
    8787
     88                data_channel_set( data_channel_set&& other )
     89                {
     90                        for ( uint32 c = 0; c < other.m_size; ++c )
     91                                m_channels[c] = move( other.m_channels[c] );
     92                        m_size = other.m_size;
     93                        other.m_size = 0;
     94                }
     95
     96                data_channel_set& operator=( data_channel_set&& other )
     97                {
     98                        if ( this != &other )
     99                        {
     100                                for ( uint32 c = 0; c < other.m_size; ++c )
     101                                        m_channels[c] = move( other.m_channels[c] );
     102                                m_size = other.m_size;
     103                                other.m_size = 0;
     104                        }
     105                        return *this;
     106                }
     107
    88108                size_t size() const { return m_size; }
    89109
  • trunk/nv/interface/mesh_data.hh

    r420 r421  
    7474                }
    7575
    76                 data_channel_set* rlease_node_data( size_t i )
    77                 {
    78                         data_channel_set* result = m_nodes[i].data;
    79                         m_nodes[i].data = nullptr;
    80                         return result;
    81                 }
     76//              data_channel_set* rlease_node_data( size_t i )
     77//              {
     78//                      data_channel_set* result = m_nodes[i].data;
     79//                      m_nodes[i].data = nullptr;
     80//                      return result;
     81//              }
    8282
    8383                bool is_flat() const { return m_flat; }
  • trunk/nv/io/string_table.hh

    r395 r421  
    7979
    8080                string_table_creator();
    81                 index insert( const std::string& s );
     81                index insert( const string_view& s );
    8282                string_table* create_table() const;
    8383                uint32 dump_size() const;
    8484                void dump( nv::stream* out ) const;
    8585                const char* get( index i ) const;
    86                 index get( const std::string& s ) const;
     86                index get( const string_view& s ) const;
    8787                void clear();
    8888        private:
    89                 unordered_map< std::string, index > m_map;
     89                unordered_map< uint64, index > m_map;
    9090                vector< offset > m_offsets;
    9191                vector< char >   m_data;
  • trunk/src/formats/md5_loader.cc

    r420 r421  
    520520        for ( uint32 i = 0; i < size; ++i )
    521521        {
    522                 data_channel_set_creator( m_meshes[i] ).move_to( meshes[i] );
     522                meshes[i] = move( *m_meshes[i] );
    523523                delete m_meshes[i];
    524524                m_meshes[i] = nullptr;
  • trunk/src/formats/nmd_loader.cc

    r420 r421  
    5858        for ( uint32 i = 0; i < size; ++i )
    5959        {
    60                 data_channel_set_creator( m_meshes[i] ).move_to( meshes[i] );
     60                meshes[i] = move( *m_meshes[i] );
    6161                delete m_meshes[i];
    6262        }
  • trunk/src/io/string_table.cc

    r406 r421  
    1212}
    1313
    14 nv::string_table_creator::index nv::string_table_creator::insert( const std::string& s )
     14nv::string_table_creator::index nv::string_table_creator::insert( const string_view& s )
    1515{
    16         auto i = m_map.find( s );
     16        uint64 hash_value = hash_string< uint64 >( s.data() );
     17        auto i = m_map.find( hash_value );
    1718        if ( i != m_map.end() )
    1819        {
    1920                return i->second;
    2021        }
    21         const char* cs = s.c_str();
     22        const char* cs = s.data();
    2223        uint32 cs_size = s.size() + 1;
    2324        NV_ASSERT( m_offsets.size() < index(-1), "Too many strings!" );
     
    2728        m_data.resize( dsize + cs_size );
    2829        raw_copy( cs, cs + cs_size, m_data.data() + dsize );
    29         m_map[ s ] = result;
     30        m_map[ hash_value ] = result;
    3031        return result;
    3132}
     
    5556}
    5657
    57 nv::string_table_creator::index nv::string_table_creator::get( const std::string& s ) const
     58nv::string_table_creator::index nv::string_table_creator::get( const string_view& s ) const
    5859{
    59         auto i = m_map.find( s );
     60        uint64 hash_value = hash_string< uint64 >( s.data() );
     61        auto i = m_map.find( hash_value );
    6062        if ( i != m_map.end() )
    6163        {
Note: See TracChangeset for help on using the changeset viewer.