mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
Some code improvements
* Rewrite empty string checks more idiomatically. * Change strings.ToLower comparisons to strings.EqualFold. * Rewrite switch statement with only one case as if.
This commit is contained in:
@@ -167,7 +167,7 @@ func (h *Handler) AddUser(ctx context.Context, user *protocol.MemoryUser) error
|
||||
}
|
||||
|
||||
func (h *Handler) RemoveUser(ctx context.Context, email string) error {
|
||||
if len(email) == 0 {
|
||||
if email == "" {
|
||||
return newError("Email must not be empty.")
|
||||
}
|
||||
if !h.usersByEmail.Remove(email) {
|
||||
|
||||
@@ -149,7 +149,7 @@ func (v *TimedUserValidator) Remove(email string) bool {
|
||||
email = strings.ToLower(email)
|
||||
idx := -1
|
||||
for i, u := range v.users {
|
||||
if strings.ToLower(u.user.Email) == email {
|
||||
if strings.EqualFold(u.user.Email, email) {
|
||||
idx = i
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user