Skip to content

Commit 007c844

Browse files
osjcnerzhul
authored andcommitted
Optimize interaction distance checker (#8193)
The "what" parameter is being passed by value, most likely by accident as the type is "const std::string". Convert it to a reference by adding the missing "&".
1 parent 557afdc commit 007c844

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/network/serverpackethandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ void Server::handleCommand_Respawn(NetworkPacket* pkt)
952952
// the previous addition has been successfully removed
953953
}
954954

955-
bool Server::checkInteractDistance(RemotePlayer *player, const f32 d, const std::string what)
955+
bool Server::checkInteractDistance(RemotePlayer *player, const f32 d, const std::string &what)
956956
{
957957
PlayerSAO *playersao = player->getPlayerSAO();
958958
const InventoryList *hlist = playersao->getInventory()->getList("hand");

src/server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class Server : public con::PeerHandler, public MapEventReceiver,
477477
void RespawnPlayer(session_t peer_id);
478478
void DeleteClient(session_t peer_id, ClientDeletionReason reason);
479479
void UpdateCrafting(RemotePlayer *player);
480-
bool checkInteractDistance(RemotePlayer *player, const f32 d, const std::string what);
480+
bool checkInteractDistance(RemotePlayer *player, const f32 d, const std::string &what);
481481

482482
void handleChatInterfaceEvent(ChatEvent *evt);
483483

0 commit comments

Comments
 (0)