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:
Jaw0r3k
2023-09-06 12:24:19 +02:00
committed by GitHub
parent cb11c56a0b
commit 90ca02880a
3 changed files with 52 additions and 4 deletions

View File

@@ -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;
}
/**