esx-framework / esx_core

Official Repo For core resources for esx-legacy
https://documentation.esx-framework.org/
GNU General Public License v3.0
368 stars 733 forks source link

[Feature Request] - About GetPlayerFromIdentifier #1350

Closed idontknowtoobrother closed 4 months ago

idontknowtoobrother commented 5 months ago

I'm not pro of programming but I just guess. What if we had 100 players in server. Is it will have like 200 players. 100 for real usage with code or implement. another 100 players just wait for call by ESX.GetPlayerFromIdentifier

--- file: [core]\es_extended\server\functions.lua
--- line: 315
function ESX.GetPlayerFromIdentifier(identifier)
    return Core.playersByIdentifier[identifier]
end

--- file: [core]\es_extended\server\main.lua
--- line: 252
ESX.Players[playerId] = xPlayer
Core.playersByIdentifier[identifier] = xPlayer

This is I think it should be idk it's will help or not. ty and sorry if I was wrong. :D

--- file: [core]\es_extended\server\functions.lua
--- line: 315
function ESX.GetPlayerFromIdentifier(identifier)
    return ESX.Players[Core.playersByIdentifierIndexPtr[identifier]]
end

--- file: [core]\es_extended\server\main.lua
--- line: 252
ESX.Players[playerId] = xPlayer
Core.playersByIdentifierIndexPtr[identifier] = tonumber(xPlayer.source)
Gellipapa commented 5 months ago

@idontknowtoobrother Hi! I'm not quite sure what the exact problem is here, can you describe in more detail what your experience? Thanks

idontknowtoobrother commented 5 months ago

I concern about memory consume with "Core.playersByIdentifier" is it duplicate player or reference?

tomiichx commented 5 months ago

I concern about memory consume with "Core.playersByIdentifier" is it duplicate player or reference?

Memory usage? Lua is pretty fast and 100-200 items (even more) is not even close for it to be a problem.

Gellipapa commented 4 months ago

Hi! @idontknowtoobrother Yes, I wouldn't think that's a problem either, but if the new uniqueID logic is implemented, we'll probably eliminate these separate tables, but thanks for the concern. 👍

idontknowtoobrother commented 4 months ago

Hi! @idontknowtoobrother Yes, I wouldn't think that's a problem either, but if the new uniqueID logic is implemented, we'll probably eliminate these separate tables, but thanks for the concern. 👍

ty bro. I tried to print in "playersByIdentifier" its a reference to player so it's not consume memory like duplicated I didn't concern about it now. I'm just newbie's in Lua and thanks for help!!

idontknowtoobrother commented 4 months ago

I concern about memory consume with "Core.playersByIdentifier" is it duplicate player or reference?

Memory usage? Lua is pretty fast and 100-200 items (even more) is not even close for it to be a problem.

I know that pretty fast but doesn't mean we can code everything by doesn't care about performance. I trust about try hard to manage data structure and in correct way can give best performance and quality product.