Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

player_manager.GetPlayerClassTable(Player ply) #2038

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MerekiDor
Copy link

This is a method to access player class definition tables more quickly.

Instead of doing this:

player_manager.GetPlayerClasses()[ player_manager.GetPlayerClass( ply ) ]

We can do this:

player_manager.GetPlayerClassTable( ply )

When I access the class table, I still create a deep copy of the table before it is returned, since we don't want players to mess with the internal tables! However, it should be more performant, because I avoid copying the entire Type table.

It's a very simple change that I came up with while working with player classes for my gamemode, but I'd be glad to contribute even something as small as this.

A method to access a player class table more quickly.
While it's nothing new - as we can already access the table of player classes and index it - it's a bit more elegant and performant, as it doesn't have to create a deep copy of the whole table.
@Denneisk
Copy link
Contributor

Wouldn't it be more efficient to copy the single element instead of the entire Type table?

@MerekiDor
Copy link
Author

Oh my. I thought this was exactly what I did, but now that I double-checked, I still copy the entire Type table, even though my description suggests otherwise.

@MerekiDor
Copy link
Author

Updated & fixed, hopefully. I should keep my eyes peeled next time... Thanks for noticing.

@robotboy655 robotboy655 added the Addition The pull request adds new functionality. label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Addition The pull request adds new functionality.
Projects
None yet
3 participants