Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
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
go
Commits
4438f502
Commit
4438f502
authored
Feb 09, 2011
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buffer.go: minor optimization, expanded comment
R=r CC=golang-dev
https://golang.org/cl/4169043
parent
334f52ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
src/pkg/bytes/buffer.go
src/pkg/bytes/buffer.go
+6
-3
No files found.
src/pkg/bytes/buffer.go
View file @
4438f502
...
...
@@ -154,17 +154,20 @@ func (b *Buffer) ReadFrom(r io.Reader) (n int64, err os.Error) {
}
// WriteTo writes data to w until the buffer is drained or an error
// occurs. The return value n is the number of bytes written.
// occurs. The return value n is the number of bytes written; it always
// fits into an int, but it is int64 to match the io.WriterTo interface.
// Any error encountered during the write is also returned.
func
(
b
*
Buffer
)
WriteTo
(
w
io
.
Writer
)
(
n
int64
,
err
os
.
Error
)
{
b
.
lastRead
=
opInvalid
for
b
.
off
<
len
(
b
.
buf
)
{
if
b
.
off
<
len
(
b
.
buf
)
{
m
,
e
:=
w
.
Write
(
b
.
buf
[
b
.
off
:
])
n
+=
int64
(
m
)
b
.
off
+=
m
n
=
int64
(
m
)
if
e
!=
nil
{
return
n
,
e
}
// otherwise all bytes were written, by definition of
// Write method in io.Writer
}
// Buffer is now empty; reset.
b
.
Truncate
(
0
)
...
...
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