Index: trunk/nv/gl/gl_device.hh
===================================================================
--- trunk/nv/gl/gl_device.hh	(revision 360)
+++ trunk/nv/gl/gl_device.hh	(revision 361)
@@ -40,8 +40,8 @@
 
 		gl_device();
-		virtual image_data* create_image_data( const std::string& filename ); // temporary
+		virtual image_data* create_image_data( string_ref filename ); // temporary
 		virtual image_data* create_image_data( const uint8* data, uint32 size ); // temporary
 
-		virtual program create_program( const string& vs_source, const string& fs_source );
+		virtual program create_program( string_ref vs_source, string_ref fs_source );
 		virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr );
 		virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr );
@@ -62,9 +62,9 @@
 	
 	private:
-		bool compile( gl_program_info* p, const string& vertex_program, const string& fragment_program );
+		bool compile( gl_program_info* p, string_ref vertex_program, string_ref fragment_program );
+		bool compile( uint32 sh_type, string_ref shader_code, unsigned& glid );
 		void update_uniforms( gl_program_info* p );
 		void load_attributes( gl_program_info* p );
 		void load_uniforms( gl_program_info* p );
-		bool compile( uint32 sh_type, const std::string& shader_code, unsigned& glid );
 		std::string m_shader_header;
 		handle_store< gl_texture_info, texture >         m_textures;
Index: trunk/nv/interface/device.hh
===================================================================
--- trunk/nv/interface/device.hh	(revision 360)
+++ trunk/nv/interface/device.hh	(revision 361)
@@ -156,10 +156,10 @@
 			initialize_engine_uniforms();
 		}
-		virtual program create_program( const string& vs_source, const string& fs_source ) = 0;
+		virtual program create_program( string_ref vs_source, string_ref fs_source ) = 0;
 		virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr ) = 0;
 		virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) = 0;
 		// TODO: remove?
 		virtual texture create_texture( ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) { return create_texture( TEXTURE_2D, size, aformat, asampler, data ); }
-		virtual image_data* create_image_data( const std::string& filename ) = 0; // temporary
+		virtual image_data* create_image_data( string_ref filename ) = 0; // temporary
 		virtual image_data* create_image_data( const uint8* data, uint32 size ) = 0; // temporary
 		virtual void release( texture ) = 0;
Index: trunk/nv/lua/lua_state.hh
===================================================================
--- trunk/nv/lua/lua_state.hh	(revision 360)
+++ trunk/nv/lua/lua_state.hh	(revision 361)
@@ -296,5 +296,6 @@
 			size_t get_size();
 			bool has_field( string_ref element );
-			std::string get_string( string_ref element, string_ref defval = string_ref() );
+			std::string get_std_string( string_ref element, string_ref defval = string_ref() );
+			const_string get_string( string_ref element, string_ref defval = string_ref() );
 			char get_char( string_ref element, char defval = ' ' );
 			int get_integer( string_ref element, int defval = 0 );
Index: trunk/src/engine/particle_engine.cc
===================================================================
--- trunk/src/engine/particle_engine.cc	(revision 360)
+++ trunk/src/engine/particle_engine.cc	(revision 361)
@@ -300,5 +300,5 @@
 void nv::particle_engine::load( lua::table_guard& table )
 {
-	std::string id = table.get_string( "id" );
+	std::string id = table.get_std_string( "id" );
 	if ( id == "" )
 	{
@@ -317,5 +317,5 @@
 	data.affector_count  = 0;
 
-	std::string orientation = table.get_string( "orientation", "point" );
+	const_string orientation = table.get_string( "orientation", "point" );
 	if ( orientation == "point" )                     { data.orientation = particle_orientation::POINT; }
 	else if ( orientation == "oriented" )             { data.orientation = particle_orientation::ORIENTED; }
@@ -329,5 +329,5 @@
 	}
 
-	std::string origin = table.get_string( "origin", "center" );
+	const_string origin = table.get_string( "origin", "center" );
 	if      ( origin == "center" )        { data.origin = particle_origin::CENTER; }
 	else if ( origin == "top_left" )      { data.origin = particle_origin::TOP_LEFT; }
@@ -353,6 +353,6 @@
 	{
 		lua::table_guard element( table, i+1 );
-		std::string type     = element.get_string("type");
-		std::string sub_type = element.get_string("sub_type");
+		const_string type     = element.get_string("type");
+		std::string sub_type = element.get_std_string("sub_type");
 		if ( type == "emmiter" )
 		{
Index: trunk/src/engine/program_manager.cc
===================================================================
--- trunk/src/engine/program_manager.cc	(revision 360)
+++ trunk/src/engine/program_manager.cc	(revision 361)
@@ -49,5 +49,5 @@
 	if ( table.is_string( "files" ) )
 	{
-		out += nv::slurp( table.get_string( "files" ) );
+		out += nv::slurp( table.get_std_string( "files" ) );
 	}
 	else if ( table.is_table( "files" ) )
@@ -65,10 +65,10 @@
 	if ( table.is_string( "file" ) )
 	{
-		out += "#line 1\n"+nv::slurp( table.get_string( "file" ) );
+		out += "#line 1\n" + nv::slurp( table.get_std_string( "file" ) );
 	}
 
 	if ( table.is_string( "source" ) )
 	{
-		out += table.get_string( "source" );
+		out += table.get_std_string( "source" );
 	}
 }
Index: trunk/src/engine/resource_system.cc
===================================================================
--- trunk/src/engine/resource_system.cc	(revision 360)
+++ trunk/src/engine/resource_system.cc	(revision 361)
@@ -35,5 +35,5 @@
 		lua::table_guard sub_table( table, i+1 );
 		resource_id rid = load_resource( sub_table );
-		if ( rid != 0 ) m_names[ sub_table.get_string("id") ] = rid;
+		if ( rid != 0 ) m_names[ sub_table.get_std_string("id") ] = rid;
 	}
 }
Index: trunk/src/gl/gl_device.cc
===================================================================
--- trunk/src/gl/gl_device.cc	(revision 360)
+++ trunk/src/gl/gl_device.cc	(revision 361)
@@ -22,5 +22,5 @@
 }
 
-program gl_device::create_program( const string& vs_source, const string& fs_source )
+program gl_device::create_program( string_ref vs_source, string_ref fs_source )
 {
 	program result = m_programs.create();
@@ -35,11 +35,11 @@
 // this is a temporary function that will be removed once we find a way to 
 // pass binary file data around
-image_data* gl_device::create_image_data( const std::string& filename )
+image_data* gl_device::create_image_data( string_ref filename )
 {
 	load_sdl_image_library();
-	SDL_Surface* image = IMG_Load( filename.c_str() );
+	SDL_Surface* image = IMG_Load( filename.data() );
 	if (!image)
 	{
-		NV_LOG( LOG_ERROR, "Image file " << filename.c_str() << " not found!" );
+		NV_LOG( LOG_ERROR, "Image file " << filename << " not found!" );
 		return nullptr;
 	}
@@ -254,5 +254,5 @@
 }
 
-bool nv::gl_device::compile( gl_program_info* p, const string& vertex_program, const string& fragment_program )
+bool nv::gl_device::compile( gl_program_info* p, string_ref vertex_program, string_ref fragment_program )
 {
 	if (!compile( GL_VERTEX_SHADER,   vertex_program, p->glidv ))   { return false; }
@@ -397,11 +397,12 @@
 }
 
-bool nv::gl_device::compile( uint32 sh_type, const std::string& shader_code, unsigned& glid )
+bool nv::gl_device::compile( uint32 sh_type, string_ref shader_code, unsigned& glid )
 {
 	glid = glCreateShader( sh_type );
 
-	const char* pc = shader_code.c_str();
-
-	glShaderSource( glid,   1, &pc, 0 );
+	const char* pc = shader_code.data();
+	int l = shader_code.length();
+
+	glShaderSource( glid, 1, &pc, &l );
 	glCompileShader( glid );
 
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 360)
+++ trunk/src/lua/lua_state.cc	(revision 361)
@@ -179,10 +179,40 @@
 }
 
-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;
+string lua::table_guard::get_std_string( string_ref element, string_ref defval /*= string_ref() */ )
+{
+	lua_getfield( m_state, -1, element.data() );
+	size_t l = 0;
+	const char* str = nullptr;
+	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
+	{
+		str = lua_tolstring( m_state, -1, &l );
+	}
+	else
+	{
+		l = defval.size();
+		str = defval.data();
+	}
+	std::string result( str, l );
+	lua_pop( m_state, 1 );
+	return result;
+}
+
+const_string lua::table_guard::get_string( string_ref element, string_ref defval /*= string_ref() */ )
+{
+ 	lua_getfield( m_state, -1, element.data() );
+ 	size_t l = 0;
+ 	const char* str = nullptr;
+ 	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
+ 	{
+ 		str = lua_tolstring( m_state, -1, &l );
+ 	}
+ 	else
+ 	{
+ 		l = defval.size();
+ 		str = defval.data();
+ 	}
+ 	const_string result( str, l );
+ 	lua_pop( m_state, 1 );
+ 	return result;
 }
 
