In the old days of scanning for nameplates JamPlates used the method of declaring variables as arguments to reserve memory.
Edit: Think there was a misunderstanding. The global function was localized because it bothered me.
Lua Code:
-- get/set mapID somewhere/somehow
local function GetPlayerMapPos(px, py) -- declare variables as arguments
-- some stuff here
px, py = C_Map.GetPlayerMapPosition(mapID, "player"):GetXY()
-- more stuff
end