mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-25 01:08:50 +01:00
Improve perf due to slow localeCompare
This commit is contained in:
parent
3e4e4d179b
commit
5f48f92c11
1 changed files with 5 additions and 3 deletions
|
@ -7,6 +7,10 @@ import states from '../utils/states';
|
||||||
import Avatar from './avatar';
|
import Avatar from './avatar';
|
||||||
import EmojiText from './emoji-text';
|
import EmojiText from './emoji-text';
|
||||||
|
|
||||||
|
const nameCollator = new Intl.Collator('en', {
|
||||||
|
sensitivity: 'base',
|
||||||
|
});
|
||||||
|
|
||||||
function NameText({
|
function NameText({
|
||||||
account,
|
account,
|
||||||
instance,
|
instance,
|
||||||
|
@ -36,9 +40,7 @@ function NameText({
|
||||||
(trimmedUsername === trimmedDisplayName ||
|
(trimmedUsername === trimmedDisplayName ||
|
||||||
trimmedUsername === shortenedDisplayName ||
|
trimmedUsername === shortenedDisplayName ||
|
||||||
trimmedUsername === shortenedAlphaNumericDisplayName ||
|
trimmedUsername === shortenedAlphaNumericDisplayName ||
|
||||||
trimmedUsername.localeCompare?.(shortenedDisplayName, 'en', {
|
nameCollator.compare(trimmedUsername, shortenedDisplayName) === 0)
|
||||||
sensitivity: 'base',
|
|
||||||
}) === 0)
|
|
||||||
) {
|
) {
|
||||||
username = null;
|
username = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue