Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mf
go-multiaddr
Commits
67926707
Commit
67926707
authored
Dec 14, 2021
by
Marten Seemann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize FilterAddrs implementation
parent
334b79e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
multiaddr.go
multiaddr.go
+5
-5
No files found.
multiaddr.go
View file @
67926707
...
...
@@ -189,14 +189,14 @@ func (m *multiaddr) ValueForProtocol(code int) (value string, err error) {
// If all filters return true, the address is kept.
func
FilterAddrs
(
a
[]
Multiaddr
,
filters
...
func
(
Multiaddr
)
bool
)
[]
Multiaddr
{
b
:=
make
([]
Multiaddr
,
0
,
len
(
a
))
addrloop
:
for
_
,
addr
:=
range
a
{
good
:=
true
for
_
,
filter
:=
range
filters
{
good
=
good
&&
filter
(
addr
)
}
if
good
{
b
=
append
(
b
,
addr
)
if
!
filter
(
addr
)
{
continue
addrloop
}
}
b
=
append
(
b
,
addr
)
}
return
b
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment