mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
perf(RoleManager): dont call Role#position getter twice per role (#9352)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -307,11 +307,14 @@ class RoleManager extends CachedManager {
|
|||||||
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'role', 'Role nor a Snowflake');
|
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'role', 'Role nor a Snowflake');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolvedRole1.position === resolvedRole2.position) {
|
const role1Position = resolvedRole1.position;
|
||||||
|
const role2Position = resolvedRole2.position;
|
||||||
|
|
||||||
|
if (role1Position === role2Position) {
|
||||||
return Number(BigInt(resolvedRole2.id) - BigInt(resolvedRole1.id));
|
return Number(BigInt(resolvedRole2.id) - BigInt(resolvedRole1.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolvedRole1.position - resolvedRole2.position;
|
return role1Position - role2Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user