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
2999d4ef
Commit
2999d4ef
authored
Oct 01, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small Join optimizations
parent
0f158f11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
util.go
util.go
+9
-4
No files found.
util.go
View file @
2999d4ef
...
...
@@ -18,6 +18,14 @@ func Split(m Multiaddr) []Multiaddr {
// Join returns a combination of addresses.
func
Join
(
ms
...
Multiaddr
)
Multiaddr
{
switch
len
(
ms
)
{
case
0
:
// empty multiaddr, unfortunately, we have callers that rely on
// this contract.
return
multiaddr
{}
case
1
:
return
ms
[
0
]
}
length
:=
0
bs
:=
make
([][]
byte
,
len
(
ms
))
...
...
@@ -29,10 +37,7 @@ func Join(ms ...Multiaddr) Multiaddr {
bidx
:=
0
b
:=
make
([]
byte
,
length
)
for
_
,
mb
:=
range
bs
{
for
i
:=
range
mb
{
b
[
bidx
]
=
mb
[
i
]
bidx
++
}
bidx
+=
copy
(
b
[
bidx
:
],
mb
)
}
return
multiaddr
{
bytes
:
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