Switch from instantiating permission objects for every permissions check
zml2008 opened this issue · 9 comments
Creating a new permissions object is a fairly expensive operation involving recalculating permissibles for any player. What you use in your plugin is the most inefficient way to access Permission objects, creating a new instance for every check. This is enough of a performance problem that users are opening bugs on PEX complaining about it.
There are (at least) two ways to go about fixing it.
a) Use string lookup for permissions. This is probably the simplest (and what most plugins do)
b) Fetch permission objects from Bukkit's cache -- plugin.getServer().getPluginManager().getPermission(String);
This can be helpful if you want to access details of permissions other than the node.
@zml2008 does my solution seem sufficient?
markhughes@4fa356b#diff-38c4acee5bf79a734b621ae92d44ffc1R107
@zml2008 hows it looking now? :)
Looks better, but Bukkit has its own store of Permission objects -- Bukkit.getServer().getPluginManager().get- /addPermission(Permission). Those should be used instead to capture the plugin.yml information about the permissions.
might want to add an additional check to addPermission if the returned
permission is null just to prevent that possibility.
On Thu, May 15, 2014 at 7:40 PM, Mark Hughes [email protected]:
I'm half asleep still, check the actual solution.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-43289754
.
Do you mean, even though is check is in place?
oh, didn't see that part. If that's there, then that fix is good.
On Thu, May 15, 2014 at 8:28 PM, Mark Hughes [email protected]:
Do you mean, even though is check is in place?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-43292518
.