[vlc-devel] commit: Use pushliteral instead of pushstring where possible. Saves a strlen call. (Antoine Cellerier )

git version control git at videolan.org
Sat Feb 27 22:05:40 CET 2010


vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Fri Feb 26 12:14:26 2010 +0100| [f782f86eb4b103a7fc7c7c9454dc838e9e2438f0] | committer: Antoine Cellerier 

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f782f86eb4b103a7fc7c7c9454dc838e9e2438f0
---

 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 444092d..4460e12 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 0904704..90eec66 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 36c5409..a10a5f3 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 f7d9d10..55de023 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 a5bb09f..85e1f59 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 c782022..9c86a28 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;
 }




More information about the vlc-devel mailing list