Skip to content
Snippets Groups Projects
Commit 76c7db28 authored by Josh Brooks's avatar Josh Brooks
Browse files

Reach an error case, Speed up map backend

parent a6c1880d
No related branches found
No related tags found
No related merge requests found
......@@ -38,14 +38,9 @@ func (m *MapImpl) GetUser(user *User) (*User, error) {
"User %+v has not been added!", user))
}*/
//Flatten map into a list
users := make([]*User, 0)
for _, value := range m.Users {
users = append(users, value)
}
//Iterate through the list of users and find matching values
for _, u := range users {
for _, u := range m.Users {
if bytes.Compare(u.Id, user.Id) == 0 && bytes.Compare(u.Id, make([]byte, 0)) != 0 {
m.lock.Unlock()
return u, nil
......@@ -70,9 +65,7 @@ func (m *MapImpl) GetUser(user *User) (*User, error) {
m.lock.Unlock()
return u, nil
}
}
m.lock.Unlock()
return NewUser(), errors.New("Unable to find any user with those values")
}
......@@ -36,7 +36,7 @@ func TestSearch_InvalidArgs(t *testing.T) {
// so.. low priority.
msgs := []string{
"EMAIL rick@elixxir.io",
"GETKEY MORETHAN 1ARG",
"notEMAIL rick@elixxir.io",
}
msg := NewMessage(msgs[0], cmixproto.Type_UDB_SEARCH)
......@@ -44,6 +44,8 @@ func TestSearch_InvalidArgs(t *testing.T) {
msg = NewMessage(msgs[1], cmixproto.Type_UDB_SEARCH)
sl.Hear(msg,false)
}
// Test invalid search type
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment