Index: trunk/src/lua/lua_map_area.cc
===================================================================
--- trunk/src/lua/lua_map_area.cc	(revision 359)
+++ trunk/src/lua/lua_map_area.cc	(revision 360)
@@ -57,5 +57,5 @@
 	if ( lua_istable( L , index ) )
 	{
-		lua_pushstring( L, "__map_area_ptr" );
+		lua_pushliteral( L, "__map_area_ptr" );
 		lua_rawget( L, index );
 		if ( lua_isuserdata( L, -1 ) )
@@ -96,5 +96,5 @@
 static int nlua_map_area_tostring( lua_State* L )
 {
-	lua_pushstring( L, "map_area" );
+	lua_pushliteral ( L, "map_area" );
 	return 1;
 }
@@ -236,5 +236,5 @@
 {
 	lua_rawgeti( L, LUA_REGISTRYINDEX, object_index.get() );
-	lua_pushstring( L, "__map_area_ptr" );
+	lua_pushliteral( L, "__map_area_ptr" );
 	lua_pushlightuserdata( L, (map_area*)area );
 	lua_rawset( L, -3 );
Index: trunk/src/lua/lua_path.cc
===================================================================
--- trunk/src/lua/lua_path.cc	(revision 359)
+++ trunk/src/lua/lua_path.cc	(revision 360)
@@ -18,5 +18,5 @@
 	size_t point = spath.find( '.' );
 
-	while ( point != std::string::npos )
+	while ( point != string_ref::npos )
 	{
 		m_elements[m_count].str    = spath.data();
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 359)
+++ trunk/src/lua/lua_state.cc	(revision 360)
@@ -80,9 +80,9 @@
 }
 
-void lua::state_wrapper::register_native_function( lfunction f, const char* name )
+void lua::state_wrapper::register_native_function( lfunction f, string_ref name )
 {
 	if ( m_global ) push_global_table();
 	lua_pushcfunction( m_state, f );
-	lua_setfield( m_state, -2, name );
+	lua_setfield( m_state, -2, name.data() );
 	if ( m_global ) pop_global_table();
 }
@@ -129,7 +129,6 @@
 	if ( status != 0 )
 	{
-		std::string error = lua_tostring( m_state, -1 );
+		NV_LOG( LOG_ERROR, "Lua error : " << lua_tostring( m_state, -1 ) );
 		lua_pop( m_state, 1 );
-		NV_LOG( LOG_ERROR, "Lua error : " << error )
 	}
 	return status;
@@ -172,7 +171,7 @@
 }
 
-bool lua::table_guard::has_field( const string& element )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+bool lua::table_guard::has_field( string_ref element )
+{
+	lua_getfield( m_state, -1, element.data() );
 	bool result = !( lua_isnil( m_state, -1 ) );
 	lua_pop( m_state, 1 );
@@ -180,15 +179,15 @@
 }
 
-string lua::table_guard::get_string( const string& element, const string& defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.c_str() );
-	string result( ( lua_type( m_state, -1 ) == LUA_TSTRING ) ? lua_tostring( m_state, -1 ) : defval );
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-char lua::table_guard::get_char( const string& element, char defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+string lua::table_guard::get_string( string_ref element, string_ref defval /*= string_ref() */ )
+{
+	lua_getfield( m_state, -1, element.data() );
+	string result( ( lua_type( m_state, -1 ) == LUA_TSTRING ) ? lua_tostring( m_state, -1 ) : defval.to_string() );
+	lua_pop( m_state, 1 );
+	return result;
+}
+
+char lua::table_guard::get_char( string_ref element, char defval /*= "" */ )
+{
+	lua_getfield( m_state, -1, element.data() );
 	char result = ( lua_type( m_state, -1 ) == LUA_TSTRING && lua_rawlen( m_state, -1 ) > 0 ) ? lua_tostring( m_state, -1 )[0] : defval;
 	lua_pop( m_state, 1 );
@@ -196,7 +195,7 @@
 }
 
-int lua::table_guard::get_integer( const string& element, int defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+int lua::table_guard::get_integer( string_ref element, int defval /*= "" */ )
+{
+	lua_getfield( m_state, -1, element.data() );
 	lua_Integer result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tointeger( m_state, -1 ) : defval;
 	lua_pop( m_state, 1 );
@@ -204,7 +203,7 @@
 }
 
-unsigned lua::table_guard::get_unsigned( const string& element, unsigned defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+unsigned lua::table_guard::get_unsigned( string_ref element, unsigned defval /*= "" */ )
+{
+	lua_getfield( m_state, -1, element.data() );
 	unsigned result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tounsigned( m_state, -1 ) : defval;
 	lua_pop( m_state, 1 );
@@ -212,7 +211,7 @@
 }
 
-double lua::table_guard::get_double( const string& element, double defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+double lua::table_guard::get_double( string_ref element, double defval /*= "" */ )
+{
+	lua_getfield( m_state, -1, element.data() );
 	double result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tonumber( m_state, -1 ) : defval;
 	lua_pop( m_state, 1 );
@@ -221,7 +220,7 @@
 
 
-float nv::lua::table_guard::get_float( const std::string& element, float defval /*= 0.0 */ )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+float nv::lua::table_guard::get_float( string_ref element, float defval /*= 0.0 */ )
+{
+	lua_getfield( m_state, -1, element.data() );
 	float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? (float)lua_tonumber( m_state, -1 ) : defval;
 	lua_pop( m_state, 1 );
@@ -229,7 +228,7 @@
 }
 
-bool lua::table_guard::get_boolean( const string& element, bool defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+bool lua::table_guard::get_boolean( string_ref element, bool defval /*= "" */ )
+{
+	lua_getfield( m_state, -1, element.data() );
 	bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN ? lua_toboolean( m_state, -1 ) != 0 : defval;
 	lua_pop( m_state, 1 );
@@ -237,7 +236,7 @@
 }
 
-bool nv::lua::table_guard::is_table( const std::string& element )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+bool nv::lua::table_guard::is_table( string_ref element )
+{
+	lua_getfield( m_state, -1, element.data() );
 	bool result = lua_type( m_state, -1 ) == LUA_TTABLE;
 	lua_pop( m_state, 1 );
@@ -245,7 +244,7 @@
 }
 
-bool nv::lua::table_guard::is_number( const std::string& element )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+bool nv::lua::table_guard::is_number( string_ref element )
+{
+	lua_getfield( m_state, -1, element.data() );
 	bool result = lua_type( m_state, -1 ) == LUA_TNUMBER;
 	lua_pop( m_state, 1 );
@@ -253,7 +252,7 @@
 }
 
-bool nv::lua::table_guard::is_boolean( const std::string& element )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+bool nv::lua::table_guard::is_boolean( string_ref element )
+{
+	lua_getfield( m_state, -1, element.data() );
 	bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN;
 	lua_pop( m_state, 1 );
@@ -261,7 +260,7 @@
 }
 
-bool nv::lua::table_guard::is_string( const std::string& element )
-{
-	lua_getfield( m_state, -1, element.c_str() );
+bool nv::lua::table_guard::is_string( string_ref element )
+{
+	lua_getfield( m_state, -1, element.data() );
 	bool result = lua_type( m_state, -1 ) == LUA_TSTRING;
 	lua_pop( m_state, 1 );
@@ -321,11 +320,11 @@
 }
 
-int lua::state::load_string( const std::string& code, const std::string& name )
+int lua::state::load_string( string_ref code, string_ref name )
 {
 	NV_LOG( nv::LOG_TRACE, "Loading Lua string '" << name << "'");
-	return luaL_loadbuffer( m_state, code.c_str(), code.length(), name.c_str() );
-}
-
-int lua::state::load_stream( std::istream& stream, const std::string& name )
+	return luaL_loadbuffer( m_state, code.data(), code.length(), name.data() );
+}
+
+int lua::state::load_stream( std::istream& stream, string_ref name )
 {
 	NV_LOG( nv::LOG_NOTICE, "Loading Lua stream '" << name << "'");
@@ -335,11 +334,11 @@
 }
 
-int lua::state::load_file( const std::string& filename )
+int lua::state::load_file( string_ref filename )
 {
 	NV_LOG( nv::LOG_NOTICE, "Loading Lua file '" << filename << "'");
-	return luaL_loadfile( m_state, filename.c_str() );
-}
-
-bool lua::state::do_string( const std::string& code, const std::string& name, int rvalues )
+	return luaL_loadfile( m_state, filename.data() );
+}
+
+bool lua::state::do_string( string_ref code, string_ref name, int rvalues )
 {
 	lua::stack_guard( this );
@@ -353,5 +352,5 @@
 }
 
-bool lua::state::do_stream( std::istream& stream, const std::string& name )
+bool lua::state::do_stream( std::istream& stream, string_ref name )
 {
 	lua::stack_guard( this );
@@ -365,5 +364,5 @@
 }
 
-bool lua::state::do_file( const std::string& filename )
+bool lua::state::do_file( string_ref filename )
 {
 	lua::stack_guard( this );
@@ -377,5 +376,5 @@
 }
 
-int lua::state::do_current( const std::string& name, int rvalues )
+int lua::state::do_current( string_ref name, int rvalues )
 {
 	int result = lua_pcall(m_state, 0, rvalues, 0);
@@ -408,12 +407,12 @@
 }
 
-lua::ref lua::state::register_object( void* o, const char* lua_name )
+lua::ref lua::state::register_object( void* o, string_ref lua_name )
 {
 	if ( o == nullptr ) return lua::ref( lua::ref::none );
 	stack_guard guard( this );
-	lua_getglobal( m_state, lua_name );
+	lua_getglobal( m_state, lua_name.data() );
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, std::string( lua_name ) + " type not registered!" );
+		NV_THROW( runtime_error, lua_name.to_string() + " type not registered!" );
 	}
 	deep_pointer_copy( -1, o );
@@ -421,30 +420,30 @@
 }
 
-lua::ref lua::state::register_proto( const char* id, const char* storage )
+lua::ref lua::state::register_proto( string_ref id, string_ref storage )
 {
 	stack_guard guard( this );
-	lua_getglobal( m_state, storage );
+	lua_getglobal( m_state, storage.data() );
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, std::string( storage ) + " storage not registered!" );
-	}
-	lua_getfield( m_state, -1, id );
+		NV_THROW( runtime_error, storage.to_string() + " storage not registered!" );
+	}
+	lua_getfield( m_state, -1, id.data() );
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, std::string( id ) + " not found in " + std::string( storage ) + " storage!" );
+		NV_THROW( runtime_error, id.to_string() + " not found in " + storage.to_string() + " storage!" );
 	}
 	return lua::ref( luaL_ref( m_state, LUA_REGISTRYINDEX ) );
 }
 
-void lua::state::register_native_object_method( const char* lua_name, const char* name, lfunction f )
+void lua::state::register_native_object_method( string_ref lua_name, string_ref name, lfunction f )
 {
 	stack_guard guard( this );
-	lua_getglobal( m_state, lua_name );
+	lua_getglobal( m_state, lua_name.data() );
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, std::string( lua_name ) + " type not registered!" );
+		NV_THROW( runtime_error, lua_name.to_string() + " type not registered!" );
 	}
 	lua_pushcfunction( m_state, f );
-	lua_setfield( m_state, -2, name );
+	lua_setfield( m_state, -2, name.data() );
 }
 
@@ -454,5 +453,5 @@
 	stack_guard guard( this );
 	lua_rawgeti( m_state, LUA_REGISTRYINDEX, object_index.get() );
-	lua_pushstring( m_state, "__ptr" );
+	lua_pushliteral( m_state, "__ptr" );
 	lua_pushboolean( m_state, false );
 	lua_rawset( m_state, -3 );
@@ -499,9 +498,9 @@
 }
 
-void nv::lua::state::store_metadata( ref object_index, const std::string& metaname, void* pointer )
+void nv::lua::state::store_metadata( ref object_index, string_ref metaname, void* pointer )
 {
 	if ( !object_index.is_valid() ) return;
 	lua_rawgeti( m_state, LUA_REGISTRYINDEX, object_index.get() );
-	lua_pushstring( m_state, metaname.c_str() );
+	lua_pushlstring( m_state, metaname.data(), metaname.size() );
 	lua_pushlightuserdata( m_state, pointer );
 	lua_rawset( m_state, -3 );
@@ -509,11 +508,11 @@
 }
 
-void nv::lua::state::register_enum( const char* name, int value )
+void nv::lua::state::register_enum( string_ref name, int value )
 {
 	lua_pushinteger( m_state, value );
-	lua_setglobal( m_state, name );
-}
-
-nv::lua::ref nv::lua::state::register_handle_component_impl( const std::string& id, bool empty )
+	lua_setglobal( m_state, name.data() );
+}
+
+nv::lua::ref nv::lua::state::register_handle_component_impl( string_ref id, bool empty )
 {
 	int args = empty ? 1 : 2;
@@ -529,5 +528,5 @@
 	else
 		nlua_deepcopy( m_state, -2 );
-	lua_pushstring( m_state, id.c_str() );
+	lua_pushlstring( m_state, id.data(), id.size() );
 	lua_pushvalue( m_state, -2 );
 	lua_rawset( m_state, -4 );
@@ -538,5 +537,5 @@
 }
 
-void nv::lua::state::unregister_handle_component_impl( const std::string& id )
+void nv::lua::state::unregister_handle_component_impl( string_ref id )
 {
 	NV_LUA_STACK_ASSERT( m_state, -1 );
@@ -547,5 +546,5 @@
 		return;
 	}
-	lua_pushstring( m_state, id.c_str() );
+	lua_pushlstring( m_state, id.data(), id.size() );
 	lua_pushnil( m_state );
 	lua_rawset( m_state, -3 );
@@ -553,15 +552,15 @@
 }
 
-void nv::lua::state::register_singleton( const char* name, void* o )
+void nv::lua::state::register_singleton( string_ref name, void* o )
 {
 	if ( o == nullptr ) return;
 	stack_guard guard( this );
-	lua_getglobal( m_state, name );
+	lua_getglobal( m_state, name.data() );
 	if ( lua_isnil( m_state, -1 ) )
 	{
-		NV_THROW( runtime_error, std::string( name ) + " type not registered!" );
+		NV_THROW( runtime_error, name.to_string() + " type not registered!" );
 	}
 	deep_pointer_copy( -1, o );
-	lua_setglobal( m_state, name );
-}
-
+	lua_setglobal( m_state, name.data() );
+}
+
Index: trunk/src/lua/lua_values.cc
===================================================================
--- trunk/src/lua/lua_values.cc	(revision 359)
+++ trunk/src/lua/lua_values.cc	(revision 360)
@@ -191,5 +191,5 @@
 	if ( lua_istable( L , index ) )
 	{
-		lua_pushstring( L, "__ptr" );
+		lua_pushliteral( L, "__ptr" );
 		lua_rawget( L, index );
 		if ( lua_isuserdata( L, -1 ) )
