Skip to content

Commit

Permalink
Merge pull request #25816 from margelo/perf/fix-avatar-calculation
Browse files Browse the repository at this point in the history
Performance: optimize getDefaultAvatar calculation
  • Loading branch information
mountiny authored Aug 24, 2023
2 parents 85032a8 + bd1dafc commit 329cac3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libs/UserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ function getDefaultAvatar(accountID = -1) {
}

// There are 24 possible default avatars, so we choose which one this user has based
// on a simple hash of their login. Note that Avatar count starts at 1.
const accountIDHashBucket = hashText(accountID.toString(), CONST.DEFAULT_AVATAR_COUNT) + 1;
// on a simple modulo operation of their login number. Note that Avatar count starts at 1.
const accountIDHashBucket = (accountID % CONST.DEFAULT_AVATAR_COUNT) + 1;

return defaultAvatars[`Avatar${accountIDHashBucket}`];
}
Expand Down

0 comments on commit 329cac3

Please sign in to comment.