mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-20 20:24:47 +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
1 changed files with 8 additions and 2 deletions
|
@ -188,8 +188,14 @@ class Role extends Base {
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get position() {
|
get position() {
|
||||||
const sorted = this.guild._sortedRoles();
|
return this.guild.roles.cache.reduce(
|
||||||
return [...sorted.values()].indexOf(sorted.get(this.id));
|
(acc, role) =>
|
||||||
|
acc +
|
||||||
|
(this.rawPosition === role.rawPosition
|
||||||
|
? BigInt(this.id) > BigInt(role.id)
|
||||||
|
: this.rawPosition > role.rawPosition),
|
||||||
|
0,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue