id: make user id parsing more efficient
Some checks failed
Go / Lint (latest) (push) Has been cancelled
Go / Build (old, libolm) (push) Has been cancelled
Go / Build (latest, libolm) (push) Has been cancelled
Go / Build (old, goolm) (push) Has been cancelled
Go / Build (latest, goolm) (push) Has been cancelled

This commit is contained in:
Tulir Asokan 2025-04-11 17:08:52 +03:00
commit 826089e020

View file

@ -43,10 +43,10 @@ func ParseCommonIdentifier[Stringish ~string](identifier Stringish) (sigil byte,
}
sigil = identifier[0]
strIdentifier := string(identifier)
if strings.ContainsRune(strIdentifier, ':') {
parts := strings.SplitN(strIdentifier, ":", 2)
localpart = parts[0][1:]
homeserver = parts[1]
colonIdx := strings.IndexByte(strIdentifier, ':')
if colonIdx > 0 {
localpart = strIdentifier[1:colonIdx]
homeserver = strIdentifier[colonIdx+1:]
} else {
localpart = strIdentifier[1:]
}