From f782f86eb4b103a7fc7c7c9454dc838e9e2438f0 Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Fri, 26 Feb 2010 12:14:26 +0100 Subject: [PATCH] Use pushliteral instead of pushstring where possible. Saves a strlen call. --- modules/misc/lua/libs/misc.c | 2 +- modules/misc/lua/libs/net.c | 16 ++++++++-------- modules/misc/lua/libs/objects.c | 2 +- modules/misc/lua/libs/playlist.c | 8 ++++---- modules/misc/lua/libs/sd.c | 4 ++-- modules/misc/lua/libs/variables.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/misc/lua/libs/misc.c b/modules/misc/lua/libs/misc.c index 444092dada..4460e12e6b 100644 --- a/modules/misc/lua/libs/misc.c +++ b/modules/misc/lua/libs/misc.c @@ -90,7 +90,7 @@ static int vlclua_version( lua_State *L ) *****************************************************************************/ static int vlclua_copyright( lua_State *L ) { - lua_pushstring( L, COPYRIGHT_MESSAGE ); + lua_pushliteral( L, COPYRIGHT_MESSAGE ); return 1; } diff --git a/modules/misc/lua/libs/net.c b/modules/misc/lua/libs/net.c index 090470495d..90eec66871 100644 --- a/modules/misc/lua/libs/net.c +++ b/modules/misc/lua/libs/net.c @@ -263,31 +263,31 @@ static int vlclua_stat( lua_State *L ) //return luaL_error( L, "Couldn't stat %s.", psz_path ); lua_newtable( L ); if( S_ISREG( s.st_mode ) ) - lua_pushstring( L, "file" ); + lua_pushliteral( L, "file" ); else if( S_ISDIR( s.st_mode ) ) - lua_pushstring( L, "dir" ); + lua_pushliteral( L, "dir" ); #ifdef S_ISCHR else if( S_ISCHR( s.st_mode ) ) - lua_pushstring( L, "character device" ); + lua_pushliteral( L, "character device" ); #endif #ifdef S_ISBLK else if( S_ISBLK( s.st_mode ) ) - lua_pushstring( L, "block device" ); + lua_pushliteral( L, "block device" ); #endif #ifdef S_ISFIFO else if( S_ISFIFO( s.st_mode ) ) - lua_pushstring( L, "fifo" ); + lua_pushliteral( L, "fifo" ); #endif #ifdef S_ISLNK else if( S_ISLNK( s.st_mode ) ) - lua_pushstring( L, "symbolic link" ); + lua_pushliteral( L, "symbolic link" ); #endif #ifdef S_ISSOCK else if( S_ISSOCK( s.st_mode ) ) - lua_pushstring( L, "socket" ); + lua_pushliteral( L, "socket" ); #endif else - lua_pushstring( L, "unknown" ); + lua_pushliteral( L, "unknown" ); lua_setfield( L, -2, "type" ); lua_pushinteger( L, s.st_mode ); lua_setfield( L, -2, "mode" ); diff --git a/modules/misc/lua/libs/objects.c b/modules/misc/lua/libs/objects.c index 36c5409430..a10a5f3d4a 100644 --- a/modules/misc/lua/libs/objects.c +++ b/modules/misc/lua/libs/objects.c @@ -61,7 +61,7 @@ int __vlclua_push_vlc_object( lua_State *L, vlc_object_t *p_obj, if( luaL_newmetatable( L, "vlc_object" ) ) { /* Hide the metatable */ - lua_pushstring( L, "none of your business" ); + lua_pushliteral( L, "none of your business" ); lua_setfield( L, -2, "__metatable" ); if( pf_gc ) /* FIXME */ { diff --git a/modules/misc/lua/libs/playlist.c b/modules/misc/lua/libs/playlist.c index f7d9d107f4..55de0234a2 100644 --- a/modules/misc/lua/libs/playlist.c +++ b/modules/misc/lua/libs/playlist.c @@ -338,16 +338,16 @@ static int vlclua_playlist_status( lua_State *L ) switch( playlist_Status( p_playlist ) ) { case PLAYLIST_STOPPED: - lua_pushstring( L, "stopped" ); + lua_pushliteral( L, "stopped" ); break; case PLAYLIST_RUNNING: - lua_pushstring( L, "playing" ); + lua_pushliteral( L, "playing" ); break; case PLAYLIST_PAUSED: - lua_pushstring( L, "paused" ); + lua_pushliteral( L, "paused" ); break; default: - lua_pushstring( L, "unknown" ); + lua_pushliteral( L, "unknown" ); break; } PL_UNLOCK; diff --git a/modules/misc/lua/libs/sd.c b/modules/misc/lua/libs/sd.c index a5bb09fab2..85e1f59f29 100644 --- a/modules/misc/lua/libs/sd.c +++ b/modules/misc/lua/libs/sd.c @@ -185,7 +185,7 @@ static int vlclua_sd_add_item( lua_State *L ) *udata = p_input; 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_setmetatable( L, -2 ); @@ -250,7 +250,7 @@ static int vlclua_node_add_subitem( lua_State *L ) *udata = p_input; 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_setmetatable( L, -2 ); diff --git a/modules/misc/lua/libs/variables.c b/modules/misc/lua/libs/variables.c index c7820220c2..9c86a28da7 100644 --- a/modules/misc/lua/libs/variables.c +++ b/modules/misc/lua/libs/variables.c @@ -224,7 +224,7 @@ static int vlclua_command( lua_State *L ) } else { - lua_pushstring( L, "" ); + lua_pushliteral( L, "" ); } return vlclua_push_ret( L, ret ) + 1; } -- 2.39.2