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
dms3
cbor-gen
Commits
211df3b9
Unverified
Commit
211df3b9
authored
Aug 10, 2020
by
Whyrusleeping
Committed by
GitHub
Aug 10, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #35 from Stebalien/feat/optimize
optimize byte reading
parents
63aa96ca
86493506
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
utils.go
utils.go
+10
-0
No files found.
utils.go
View file @
211df3b9
...
...
@@ -247,6 +247,16 @@ func CborReadHeader(br io.Reader) (byte, uint64, error) {
}
func
readByteBuf
(
r
io
.
Reader
,
scratch
[]
byte
)
(
byte
,
error
)
{
// Reading a single byte from these buffers is much faster than copying
// into a slice.
switch
r
:=
r
.
(
type
)
{
case
*
bytes
.
Buffer
:
return
r
.
ReadByte
()
case
*
bytes
.
Reader
:
return
r
.
ReadByte
()
case
*
bufio
.
Reader
:
return
r
.
ReadByte
()
}
n
,
err
:=
r
.
Read
(
scratch
[
:
1
])
if
err
!=
nil
{
return
0
,
err
...
...
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