Index: trunk/nv/core/library.hh
===================================================================
--- trunk/nv/core/library.hh	(revision 436)
+++ trunk/nv/core/library.hh	(revision 437)
@@ -16,5 +16,4 @@
 #include <nv/common.hh>
 #include <nv/stl/string.hh>
-#include <string>
 
 namespace nv
@@ -83,5 +82,5 @@
 		 * Exact implementation depends on platform/compiler.
 		 */
-		static std::string get_error();
+		static string_view get_error();
 
 	protected:
@@ -108,5 +107,5 @@
 
 		/// Library name
-		std::string m_name;
+		const_string m_name;
 
 	};  // class Library
Index: trunk/nv/gfx/sliced_buffer.hh
===================================================================
--- trunk/nv/gfx/sliced_buffer.hh	(revision 436)
+++ trunk/nv/gfx/sliced_buffer.hh	(revision 437)
@@ -13,5 +13,5 @@
 #include <nv/common.hh>
 #include <nv/stl/math.hh>
-#include <vector> // TODO: remove
+#include <nv/stl/vector.hh> 
 
 namespace nv
@@ -25,5 +25,5 @@
 	public:
 		typedef sliced_buffer<T> cache_type;
-		typedef std::vector<T>   vector_type;
+		typedef vector<T>        vector_type;
 		typedef size_t           size_type;
 
@@ -90,6 +90,6 @@
 	{
 	public:
-		typedef std::vector<T>  vector_type;
-		typedef T               value_type;
+		typedef vector<T>  vector_type;
+		typedef T          value_type;
 		static const size_t value_type_size = sizeof(T);
 
@@ -112,5 +112,5 @@
 			if ( !m_full_update && resized )
 			{
-				m_data.erase( m_data.begin() + int( offset ), m_data.end() );
+				m_data.erase( m_data.begin() + static_cast<int>( offset ), m_data.end() );
 				m_min = nv::min<size_t>( m_min, offset );
 				m_full_update = true;
@@ -119,10 +119,10 @@
 			{
 				offset = m_data.size();
-				m_data.insert( m_data.end(), bv.cbegin(), bv.cend() );
+				m_data.append( bv.cbegin(), bv.cend() );
 			}
 			else if ( updated )
 			{
 //				raw_copy( bv.cbegin(), bv.cend(), m_data.begin() + (int)offset );
-				raw_copy( bv.data(), bv.data() + bv.size(), m_data.data() + int( offset ) );
+				raw_copy( bv.data(), bv.data() + bv.size(), m_data.data() + static_cast<int>( offset ) );
 				m_min = nv::min<size_t>( m_min, offset );
 				m_max = nv::max<size_t>( m_max, offset + bv.size() );
@@ -158,4 +158,5 @@
 			bool result = false;
 			size_t bsize = get_max_size();
+
 			if ( m_data.size() > bsize )
 			{
Index: trunk/nv/gfx/texture_atlas.hh
===================================================================
--- trunk/nv/gfx/texture_atlas.hh	(revision 436)
+++ trunk/nv/gfx/texture_atlas.hh	(revision 437)
@@ -13,6 +13,5 @@
 #include <nv/stl/math.hh>
 #include <nv/gfx/image.hh>
-//#include <nv/stl/vector.hh>
-#include <vector>
+#include <nv/stl/vector.hh>
 
 namespace nv
@@ -32,5 +31,5 @@
 		size_t m_used;
 		size_t m_border;
-		std::vector<ivec3> m_nodes;
+		vector<ivec3> m_nodes;
 	};
 
Index: trunk/nv/lua/lua_raw.hh
===================================================================
--- trunk/nv/lua/lua_raw.hh	(revision 436)
+++ trunk/nv/lua/lua_raw.hh	(revision 437)
@@ -11,5 +11,5 @@
 #include <nv/stl/vector.hh>
 #include <nv/lib/lua.hh>
-#include <string>
+#include <nv/stl/string.hh>
 
 void nlua_toflags_set( lua_State *L, int index, nv::uint8* data, nv::uint32 count );
@@ -17,5 +17,18 @@
 void nlua_toflags( lua_State *L, int index, nv::uint8* data, nv::uint32 count );
 
-std::string nlua_typecontent( lua_State* L, int idx );
+inline nv::string_view nlua_tostringview( lua_State* L, int idx )
+{
+	size_t len;
+	const char* str = lua_tolstring( L, idx, &len );
+	return nv::string_view( str, len );
+}
+
+inline void nlua_pushstringview( lua_State* L, const nv::string_view& str )
+{
+	lua_pushlstring( L, str.data(), str.size() );
+}
+
+// TODO: this is not thread safe!
+nv::string_view nlua_typecontent( lua_State* L, int idx );
 void nlua_shallowmerge( lua_State *L, int index );
 void nlua_shallowcopy( lua_State *L, int index );
@@ -33,4 +46,6 @@
 void nlua_register( lua_State *L, const char* lname, const luaL_Reg *l );
 
+
+
 #endif // NV_LUA_RAW_HH
 
Index: trunk/nv/stl/container/growing_storage.hh
===================================================================
--- trunk/nv/stl/container/growing_storage.hh	(revision 436)
+++ trunk/nv/stl/container/growing_storage.hh	(revision 437)
@@ -148,5 +148,5 @@
 		iterator erase( iterator position )
 		{
-			if ( m_size == 0 ) return;
+			if ( m_size == 0 ) return iterator();
 			iterator iend = Storage::data() + m_size;
 			InitializePolicy::destroy( position );
@@ -162,5 +162,5 @@
 			InitializePolicy::destroy( first, last );
 			iterator position = raw_alias_copy( last, iend, first );
-			m_size -= ( last - first );
+			m_size.size( m_size - ( last - first ) );
 			return position;
 		}
Index: trunk/src/core/library.cc
===================================================================
--- trunk/src/core/library.cc	(revision 436)
+++ trunk/src/core/library.cc	(revision 437)
@@ -6,4 +6,5 @@
 
 #include "nv/core/library.hh"
+#include <string>
 
 #if NV_PLATFORM == NV_WINDOWS
@@ -40,5 +41,5 @@
 void library::open( string_view name )
 {
-	m_name.assign( name.data(), name.size() );
+	m_name = name;
 	if ( !open() )
 	{
@@ -51,5 +52,5 @@
 bool nv::library::try_open( string_view name )
 {
-	m_name.assign( name.data(), name.size() );
+	m_name = name;
 	if ( !open() )
 	{
@@ -62,5 +63,5 @@
 string_view library::get_name() const
 {
-    return string_view( m_name.c_str(), m_name.size() );
+    return m_name;
 }
 
@@ -71,7 +72,7 @@
         return true;
     }
-    NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : loading..." );
+    NV_LOG_NOTICE( "library \"", m_name, "\" : loading..." );
 
-	std::string name = m_name;
+	std::string name( m_name.data(), m_name.length() );
 	std::string ext( NV_LIB_EXT );
 
@@ -85,8 +86,7 @@
     if ( m_handle == NULL )
     {
-		NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : failed to open!" );
+		NV_LOG_NOTICE( "library \"", m_name, "\" : failed to open!" );
 		return false;
     }
-    NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : loaded." );
 	return true;
 }
@@ -97,5 +97,5 @@
     if ( !result )
     {
-		NV_LOG_CRITICAL( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : can't find symbol \"", symbol, "\"" );
+		NV_LOG_CRITICAL( "library \"", m_name, "\" : can't find symbol \"", symbol, "\"" );
 		NV_ABORT( "Library symbol load failed!" );
     }
@@ -117,5 +117,5 @@
     if ( ! NV_LIB_CLOSE( m_handle ) )
     {
-        NV_LOG_ERROR( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : can't close library!" );
+        NV_LOG_ERROR( "library \"", m_name, "\" : can't close library!" );
     }
     m_handle = nullptr;
@@ -130,18 +130,16 @@
 }
 
-std::string library::get_error()
+nv::string_view library::get_error()
 {
 #if NV_PLATFORM == NV_WINDOWS
     // We do hate WinAPI for code like this, don't we?
-    LPTSTR buffer = nullptr;
-    FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
-        NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>( &buffer ), 0, NULL );
-    std::string msg( reinterpret_cast<char*>( buffer ) );
-    LocalFree( buffer );
-    return msg;
+	static TCHAR buffer[256];
+    FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+        NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>( &buffer ), 256, NULL );
+    return string_view( reinterpret_cast<char*>( buffer ) );
 #elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
-    return std::string( dlerror() );
+    return nv::string_view( dlerror() );
 #else
-    return std::string("");
+    return nv::string_view();
 #endif
 }
Index: trunk/src/gui/gui_gfx_renderer.cc
===================================================================
--- trunk/src/gui/gui_gfx_renderer.cc	(revision 436)
+++ trunk/src/gui/gui_gfx_renderer.cc	(revision 437)
@@ -235,5 +235,5 @@
 	size_t size_before = er->buffer.data().size();
 
-	std::vector< gui_quad >& qvec = er->buffer.lock();
+	vector< gui_quad >& qvec = er->buffer.lock();
 
 	qvec.clear();
Index: trunk/src/lua/lua_map_area.cc
===================================================================
--- trunk/src/lua/lua_map_area.cc	(revision 436)
+++ trunk/src/lua/lua_map_area.cc	(revision 437)
@@ -137,6 +137,5 @@
 {
 	nv::map_area* ma = to_map_area( L, 1 );
-	nv::string_view result( ma->id_to_string( ma->get_cell( to_coord( L, 2 ) ) ) );
-	lua_pushlstring( L, result.data(), result.size() );
+	nlua_pushstringview( L, ma->id_to_string( ma->get_cell( to_coord( L, 2 ) ) ) );
 	return 1;
 }
Index: trunk/src/lua/lua_nova.cc
===================================================================
--- trunk/src/lua/lua_nova.cc	(revision 436)
+++ trunk/src/lua/lua_nova.cc	(revision 437)
@@ -817,5 +817,5 @@
 	// TODO: check if nova is loaded
 	lua_pushcfunction( L, nova_register_storage );
-	lua_pushlstring( L, name.data(), name.size() );
+	nlua_pushstringview( L, name );
 	lua_call( L, 1, 1 );
 	lua_setglobal( L, constructor_name.data() );
Index: trunk/src/lua/lua_raw.cc
===================================================================
--- trunk/src/lua/lua_raw.cc	(revision 436)
+++ trunk/src/lua/lua_raw.cc	(revision 437)
@@ -7,7 +7,5 @@
 #include "nv/lua/lua_raw.hh"
 
-#include "nv/stl/string.hh"
-
-std::string nlua_typecontent( lua_State* L, int idx )
+nv::string_view nlua_typecontent( lua_State* L, int idx )
 {
 	int type = lua_type( L, idx );
@@ -19,5 +17,6 @@
 	//case LUA_TLIGHTUSERDATA	: return std::to_string( nv::uint64( lua_touserdata( L, idx ) ) ); 
 	//case LUA_TNUMBER		: return std::to_string( lua_tonumber( L, idx ) ); 
-	case LUA_TSTRING		: return lua_tostring( L, idx ); 
+	// TODO: copy to buffer?
+	case LUA_TSTRING		: return nlua_tostringview( L, idx ); 
 	case LUA_TTABLE		    : return "TABLE"; 
 	case LUA_TFUNCTION		: return "FUNCTION"; 
@@ -26,15 +25,15 @@
 	default : break; 
 	}
-	char buffer_data[64];
+	static char buffer_data[64];
 	nv::array_ref< char > buffer( buffer_data, 64 );
 	if ( type == LUA_TLIGHTUSERDATA || type == LUA_TUSERDATA )
 	{
 		size_t l = nv::uint64_to_buffer( buffer, nv::uint64( lua_touserdata( L, idx ) ) );
-		return std::string( buffer_data, l );
+		return nv::string_view( buffer.data(), buffer.size() );
 	}
 	else if ( type == LUA_TNUMBER )
 	{
 		size_t l = nv::f64_to_buffer( buffer, lua_tonumber( L, idx ) );
-		return std::string( buffer_data, l );
+		return nv::string_view( buffer.data(), buffer.size() );
 	}
 	return "UNKNOWN!";
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 436)
+++ trunk/src/lua/lua_state.cc	(revision 437)
@@ -134,5 +134,5 @@
 	if ( status != 0 )
 	{
-		NV_LOG_ERROR( "Lua error : ", lua_tostring( m_state, -1 ) );
+		NV_LOG_ERROR( "Lua error : ", nlua_tostringview( m_state, -1 ) );
 		lua_pop( m_state, 1 );
 	}
@@ -402,5 +402,5 @@
 	if (result)
 	{
-		NV_LOG_WARNING( "Failed to load string ", name, ": ", lua_tostring(m_state, -1));
+		NV_LOG_WARNING( "Failed to load string ", name, ": ", nlua_tostringview(m_state, -1));
 		return false;
 	}
@@ -414,5 +414,5 @@
 	if (result) 
 	{
-		NV_LOG_WARNING( "Failed to open file ", filename, ": ", lua_tostring( m_state, -1 ) );
+		NV_LOG_WARNING( "Failed to open file ", filename, ": ", nlua_tostringview( m_state, -1 ) );
 		return false;
 	}
@@ -425,5 +425,5 @@
 	if (result) 
 	{
-		NV_LOG_WARNING( "Failed to run script ", name, ": ", lua_tostring( m_state, -1 ) );
+		NV_LOG_WARNING( "Failed to run script ", name, ": ", nlua_tostringview( m_state, -1 ) );
 		lua_pop( m_state, 1 );
 	}
@@ -442,5 +442,5 @@
 	for ( int i = 0; i < top; ++i )
 	{
-		NV_LOG_DEBUG( "#", i+1, " - ", lua_typename(m_state, lua_type(m_state, i+1) ), " = ", nlua_typecontent(m_state, i+1).c_str() );
+		NV_LOG_DEBUG( "#", i+1, " - ", lua_typename(m_state, lua_type(m_state, i+1) ), " = ", nlua_typecontent(m_state, i+1) );
 	}
 }
@@ -546,5 +546,5 @@
 	if ( !object_index.is_valid() ) return;
 	lua_rawgeti( m_state, LUA_REGISTRYINDEX, object_index.get() );
-	lua_pushlstring( m_state, metaname.data(), metaname.size() );
+	nlua_pushstringview( m_state, metaname );
 	lua_pushlightuserdata( m_state, pointer );
 	lua_rawset( m_state, -3 );
@@ -572,5 +572,5 @@
 	else
 		nlua_deepcopy( m_state, -2 );
-	lua_pushlstring( m_state, id.data(), id.size() );
+	nlua_pushstringview( m_state, id );
 	lua_pushvalue( m_state, -2 );
 	lua_rawset( m_state, -4 );
@@ -590,5 +590,5 @@
 		return;
 	}
-	lua_pushlstring( m_state, id.data(), id.size() );
+	nlua_pushstringview( m_state, id );
 	lua_pushnil( m_state );
 	lua_rawset( m_state, -3 );
