mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
perf: linear speed position getters (#9528)
* perf(Channel): linear speed position getter (#9497) Co-authored-by: kyra <kyradiscord@gmail.com> * perf(Role): linear speed position getter --------- Co-authored-by: kyra <kyradiscord@gmail.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -228,8 +228,13 @@ class Role extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get position() {
|
||||
const sorted = this.guild._sortedRoles();
|
||||
return [...sorted.values()].indexOf(sorted.get(this.id));
|
||||
let count = 0;
|
||||
for (const role of this.guild.roles.cache.values()) {
|
||||
if (this.rawPosition > role.rawPosition) count++;
|
||||
else if (this.rawPosition === role.rawPosition && BigInt(this.id) > BigInt(role.id)) count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user