]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use more efficient lua_pushliteral
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 13 Oct 2020 18:19:45 +0000 (11:19 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 14 Oct 2020 13:50:53 +0000 (06:50 -0700)
This avoids an unnecessary call to strlen.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/rgw/rgw_lua_utils.h

index 3462e0ed68610443ea2829fc582bd9fd2f21003f..55545431b794d87b848775ed3d89e222bf11e88a 100644 (file)
@@ -95,25 +95,25 @@ void create_metatable(lua_State* L, bool toplevel, Upvalues... upvalues)
   }
   // create metatable
   [[maybe_unused]] const auto rc = luaL_newmetatable(L, MetaTable::Name().c_str());
-  lua_pushstring(L, "__index");
+  lua_pushliteral(L, "__index");
   for (const auto upvalue : upvalue_arr) {
     lua_pushlightuserdata(L, upvalue);
   }
   lua_pushcclosure(L, MetaTable::IndexClosure, upvals_size);
   lua_rawset(L, -3);
-  lua_pushstring(L, "__newindex");
+  lua_pushliteral(L, "__newindex");
   for (const auto upvalue : upvalue_arr) {
     lua_pushlightuserdata(L, upvalue);
   }
   lua_pushcclosure(L, MetaTable::NewIndexClosure, upvals_size);
   lua_rawset(L, -3);
-  lua_pushstring(L, "__pairs");
+  lua_pushliteral(L, "__pairs");
   for (const auto upvalue : upvalue_arr) {
     lua_pushlightuserdata(L, upvalue);
   }
   lua_pushcclosure(L, MetaTable::PairsClosure, upvals_size);
   lua_rawset(L, -3);
-  lua_pushstring(L, "__len");
+  lua_pushliteral(L, "__len");
   for (const auto upvalue : upvalue_arr) {
     lua_pushlightuserdata(L, upvalue);
   }