Commit f782f86e authored by Antoine Cellerier's avatar Antoine Cellerier

Use pushliteral instead of pushstring where possible. Saves a strlen call.

parent 7478dfe4
...@@ -90,7 +90,7 @@ static int vlclua_version( lua_State *L ) ...@@ -90,7 +90,7 @@ static int vlclua_version( lua_State *L )
*****************************************************************************/ *****************************************************************************/
static int vlclua_copyright( lua_State *L ) static int vlclua_copyright( lua_State *L )
{ {
lua_pushstring( L, COPYRIGHT_MESSAGE ); lua_pushliteral( L, COPYRIGHT_MESSAGE );
return 1; return 1;
} }
......
...@@ -263,31 +263,31 @@ static int vlclua_stat( lua_State *L ) ...@@ -263,31 +263,31 @@ static int vlclua_stat( lua_State *L )
//return luaL_error( L, "Couldn't stat %s.", psz_path ); //return luaL_error( L, "Couldn't stat %s.", psz_path );
lua_newtable( L ); lua_newtable( L );
if( S_ISREG( s.st_mode ) ) if( S_ISREG( s.st_mode ) )
lua_pushstring( L, "file" ); lua_pushliteral( L, "file" );
else if( S_ISDIR( s.st_mode ) ) else if( S_ISDIR( s.st_mode ) )
lua_pushstring( L, "dir" ); lua_pushliteral( L, "dir" );
#ifdef S_ISCHR #ifdef S_ISCHR
else if( S_ISCHR( s.st_mode ) ) else if( S_ISCHR( s.st_mode ) )
lua_pushstring( L, "character device" ); lua_pushliteral( L, "character device" );
#endif #endif
#ifdef S_ISBLK #ifdef S_ISBLK
else if( S_ISBLK( s.st_mode ) ) else if( S_ISBLK( s.st_mode ) )
lua_pushstring( L, "block device" ); lua_pushliteral( L, "block device" );
#endif #endif
#ifdef S_ISFIFO #ifdef S_ISFIFO
else if( S_ISFIFO( s.st_mode ) ) else if( S_ISFIFO( s.st_mode ) )
lua_pushstring( L, "fifo" ); lua_pushliteral( L, "fifo" );
#endif #endif
#ifdef S_ISLNK #ifdef S_ISLNK
else if( S_ISLNK( s.st_mode ) ) else if( S_ISLNK( s.st_mode ) )
lua_pushstring( L, "symbolic link" ); lua_pushliteral( L, "symbolic link" );
#endif #endif
#ifdef S_ISSOCK #ifdef S_ISSOCK
else if( S_ISSOCK( s.st_mode ) ) else if( S_ISSOCK( s.st_mode ) )
lua_pushstring( L, "socket" ); lua_pushliteral( L, "socket" );
#endif #endif
else else
lua_pushstring( L, "unknown" ); lua_pushliteral( L, "unknown" );
lua_setfield( L, -2, "type" ); lua_setfield( L, -2, "type" );
lua_pushinteger( L, s.st_mode ); lua_pushinteger( L, s.st_mode );
lua_setfield( L, -2, "mode" ); lua_setfield( L, -2, "mode" );
......
...@@ -61,7 +61,7 @@ int __vlclua_push_vlc_object( lua_State *L, vlc_object_t *p_obj, ...@@ -61,7 +61,7 @@ int __vlclua_push_vlc_object( lua_State *L, vlc_object_t *p_obj,
if( luaL_newmetatable( L, "vlc_object" ) ) if( luaL_newmetatable( L, "vlc_object" ) )
{ {
/* Hide the metatable */ /* Hide the metatable */
lua_pushstring( L, "none of your business" ); lua_pushliteral( L, "none of your business" );
lua_setfield( L, -2, "__metatable" ); lua_setfield( L, -2, "__metatable" );
if( pf_gc ) /* FIXME */ if( pf_gc ) /* FIXME */
{ {
......
...@@ -338,16 +338,16 @@ static int vlclua_playlist_status( lua_State *L ) ...@@ -338,16 +338,16 @@ static int vlclua_playlist_status( lua_State *L )
switch( playlist_Status( p_playlist ) ) switch( playlist_Status( p_playlist ) )
{ {
case PLAYLIST_STOPPED: case PLAYLIST_STOPPED:
lua_pushstring( L, "stopped" ); lua_pushliteral( L, "stopped" );
break; break;
case PLAYLIST_RUNNING: case PLAYLIST_RUNNING:
lua_pushstring( L, "playing" ); lua_pushliteral( L, "playing" );
break; break;
case PLAYLIST_PAUSED: case PLAYLIST_PAUSED:
lua_pushstring( L, "paused" ); lua_pushliteral( L, "paused" );
break; break;
default: default:
lua_pushstring( L, "unknown" ); lua_pushliteral( L, "unknown" );
break; break;
} }
PL_UNLOCK; PL_UNLOCK;
......
...@@ -185,7 +185,7 @@ static int vlclua_sd_add_item( lua_State *L ) ...@@ -185,7 +185,7 @@ static int vlclua_sd_add_item( lua_State *L )
*udata = p_input; *udata = p_input;
if( luaL_newmetatable( L, "input_item_t" ) ) if( luaL_newmetatable( L, "input_item_t" ) )
{ {
lua_pushstring( L, "none of your business" ); lua_pushliteral( L, "none of your business" );
lua_setfield( L, -2, "__metatable" ); lua_setfield( L, -2, "__metatable" );
} }
lua_setmetatable( L, -2 ); lua_setmetatable( L, -2 );
...@@ -250,7 +250,7 @@ static int vlclua_node_add_subitem( lua_State *L ) ...@@ -250,7 +250,7 @@ static int vlclua_node_add_subitem( lua_State *L )
*udata = p_input; *udata = p_input;
if( luaL_newmetatable( L, "input_item_t" ) ) if( luaL_newmetatable( L, "input_item_t" ) )
{ {
lua_pushstring( L, "none of your business" ); lua_pushliteral( L, "none of your business" );
lua_setfield( L, -2, "__metatable" ); lua_setfield( L, -2, "__metatable" );
} }
lua_setmetatable( L, -2 ); lua_setmetatable( L, -2 );
......
...@@ -224,7 +224,7 @@ static int vlclua_command( lua_State *L ) ...@@ -224,7 +224,7 @@ static int vlclua_command( lua_State *L )
} }
else else
{ {
lua_pushstring( L, "" ); lua_pushliteral( L, "" );
} }
return vlclua_push_ret( L, ret ) + 1; return vlclua_push_ret( L, ret ) + 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment