Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
og-rek
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
og-rek
Commits
9de0a04a
Commit
9de0a04a
authored
Feb 16, 2017
by
Kamil Kisiel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse buffer in a few other places to save on allocations
parent
9627bcd9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
ogorek.go
ogorek.go
+9
-12
No files found.
ogorek.go
View file @
9de0a04a
...
@@ -492,13 +492,12 @@ func (d *Decoder) loadBinString() error {
...
@@ -492,13 +492,12 @@ func (d *Decoder) loadBinString() error {
}
}
v
:=
binary
.
LittleEndian
.
Uint32
(
b
[
:
])
v
:=
binary
.
LittleEndian
.
Uint32
(
b
[
:
])
// TODO: use d.buf to reduce allocations?
d
.
buf
.
Reset
()
s
:=
make
([]
byte
,
v
)
_
,
err
=
io
.
CopyN
(
&
d
.
buf
,
d
.
r
,
int64
(
v
))
_
,
err
=
io
.
ReadFull
(
d
.
r
,
s
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
d
.
push
(
string
(
s
))
d
.
push
(
d
.
buf
.
String
(
))
return
nil
return
nil
}
}
...
@@ -508,13 +507,12 @@ func (d *Decoder) loadShortBinString() error {
...
@@ -508,13 +507,12 @@ func (d *Decoder) loadShortBinString() error {
return
err
return
err
}
}
// TODO: use d.buf to reduce allocations?
d
.
buf
.
Reset
()
s
:=
make
([]
byte
,
b
)
_
,
err
=
io
.
CopyN
(
&
d
.
buf
,
d
.
r
,
int64
(
b
))
_
,
err
=
io
.
ReadFull
(
d
.
r
,
s
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
d
.
push
(
string
(
s
))
d
.
push
(
d
.
buf
.
String
(
))
return
nil
return
nil
}
}
...
@@ -825,13 +823,12 @@ func (d *Decoder) loadShortBinUnicode() error {
...
@@ -825,13 +823,12 @@ func (d *Decoder) loadShortBinUnicode() error {
return
err
return
err
}
}
// TODO: use d.buf to save allocations?
d
.
buf
.
Reset
()
s
:=
make
([]
byte
,
b
)
_
,
err
=
io
.
CopyN
(
&
d
.
buf
,
d
.
r
,
int64
(
b
))
_
,
err
=
io
.
ReadFull
(
d
.
r
,
s
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
d
.
push
(
string
(
s
))
d
.
push
(
d
.
buf
.
String
(
))
return
nil
return
nil
}
}
...
...
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