mirror of
https://github.com/discordjs/discord.js.git
synced 2024-07-08 01:41:18 +12:00
perf(Role): linear speed position getter (#9493)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
parent
d4f12e0a0c
commit
8e9a2b4630
|
@ -188,8 +188,14 @@ class Role extends Base {
|
|||
* @readonly
|
||||
*/
|
||||
get position() {
|
||||
const sorted = this.guild._sortedRoles();
|
||||
return [...sorted.values()].indexOf(sorted.get(this.id));
|
||||
return this.guild.roles.cache.reduce(
|
||||
(acc, role) =>
|
||||
acc +
|
||||
(this.rawPosition === role.rawPosition
|
||||
? BigInt(this.id) > BigInt(role.id)
|
||||
: this.rawPosition > role.rawPosition),
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue