Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
user-discovery-bot
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
archives
user-discovery-bot
Commits
76c7db28
Commit
76c7db28
authored
Aug 28, 2019
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Reach an error case, Speed up map backend
parent
a6c1880d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
storage/mapBackend.go
+2
-9
2 additions, 9 deletions
storage/mapBackend.go
udb/search_test.go
+3
-1
3 additions, 1 deletion
udb/search_test.go
with
5 additions
and
10 deletions
storage/mapBackend.go
+
2
−
9
View file @
76c7db28
...
...
@@ -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"
)
}
This diff is collapsed.
Click to expand it.
udb/search_test.go
+
3
−
1
View file @
76c7db28
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment