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
f5c34dfc
Commit
f5c34dfc
authored
Sep 20, 2017
by
Jeromy Johnson
Committed by
GitHub
Sep 20, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #56 from multiformats/feat/perf
preallocate protocol slice
parents
6addc7f5
d8140735
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
10 deletions
+1
-10
multiaddr.go
multiaddr.go
+1
-10
No files found.
multiaddr.go
View file @
f5c34dfc
...
...
@@ -69,16 +69,7 @@ func (m *multiaddr) String() string {
// Protocols returns the list of protocols this Multiaddr has.
// will panic in case we access bytes incorrectly.
func
(
m
*
multiaddr
)
Protocols
()
[]
Protocol
{
// panic handler, in case we try accessing bytes incorrectly.
defer
func
()
{
if
e
:=
recover
();
e
!=
nil
{
err
:=
e
.
(
error
)
panic
(
"Multiaddr.Protocols error: "
+
err
.
Error
())
}
}()
var
ps
[]
Protocol
ps
:=
make
([]
Protocol
,
0
,
8
)
b
:=
m
.
bytes
for
len
(
b
)
>
0
{
code
,
n
,
err
:=
ReadVarintCode
(
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