Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
02df7db8
Commit
02df7db8
authored
Nov 19, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace custom findByte with bytes.IndexByte
R=rsc
https://golang.org/cl/156093
parent
bf1f63a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
25 deletions
+15
-25
Make.deps
src/pkg/Make.deps
+12
-12
bufio.go
src/pkg/bufio/bufio.go
+3
-13
No files found.
src/pkg/Make.deps
View file @
02df7db8
archive/tar.install: bytes.install io.install os.install strconv.install strings.install
asn1.install:
fmt
.install os.install reflect.install strconv.install strings.install time.install
asn1.install:
bytes.install fmt.install io
.install os.install reflect.install strconv.install strings.install time.install
big.install: rand.install
bignum.install: fmt.install
bufio.install: io.install os.install strconv.install utf8.install
bufio.install:
bytes.install
io.install os.install strconv.install utf8.install
bytes.install: os.install unicode.install utf8.install
compress/flate.install: bufio.install
bytes.install
io.install math.install os.install sort.install strconv.install
compress/gzip.install: bufio.install compress/flate.install hash
/crc32.install hash
.install io.install os.install
compress/zlib.install: bufio.install compress/flate.install hash
/adler32.install hash
.install io.install os.install
compress/flate.install: bufio.install io.install math.install os.install sort.install strconv.install
compress/gzip.install: bufio.install compress/flate.install hash
.install hash/crc32
.install io.install os.install
compress/zlib.install: bufio.install compress/flate.install hash
.install hash/adler32
.install io.install os.install
container/heap.install: sort.install
container/list.install:
container/ring.install:
...
...
@@ -16,19 +16,19 @@ crypto/block.install: fmt.install hash.install io.install os.install strconv.ins
crypto/hmac.install: crypto/md5.install crypto/sha1.install hash.install os.install
crypto/md5.install: hash.install os.install
crypto/rc4.install: os.install strconv.install
crypto/rsa.install: big.install
bytes.install
crypto/subtle.install hash.install io.install os.install
crypto/rsa.install: big.install crypto/subtle.install hash.install io.install os.install
crypto/sha1.install: hash.install os.install
crypto/subtle.install:
crypto/tls.install: bufio.install
bytes.install container/list.install crypto/hmac.install crypto/md5.install crypto/rc4.install crypto/rsa.install crypto/sha1.install crypto/subtle.install crypto/x509
.install fmt.install hash.install io.install net.install os.install strings.install time.install
crypto/x509.install: asn1.install big.install container/vector.install crypto/rsa.install
o
s.install time.install
crypto/tls.install: bufio.install
container/list.install crypto/hmac.install crypto/md5.install crypto/rc4.install crypto/rsa.install crypto/sha1.install crypto/subtle
.install fmt.install hash.install io.install net.install os.install strings.install time.install
crypto/x509.install: asn1.install big.install container/vector.install crypto/rsa.install
crypto/sha1.install hash.install os.install string
s.install time.install
debug/dwarf.install: encoding/binary.install os.install strconv.install
debug/macho.install: bytes.install debug/dwarf.install encoding/binary.install fmt.install io.install os.install strconv.install
debug/elf.install: bytes.install debug/dwarf.install encoding/binary.install fmt.install io.install os.install strconv.install
debug/gosym.install: encoding/binary.install fmt.install os.install strconv.install strings.install
debug/proc.install: container/vector.install fmt.install io.install os.install runtime.install strconv.install strings.install sync.install syscall.install
ebnf.install: container/vector.install go/scanner.install go/token.install os.install strconv.install unicode.install utf8.install
encoding/ascii85.install:
bytes.install
io.install os.install strconv.install
encoding/base64.install:
bytes.install
io.install os.install strconv.install
encoding/ascii85.install: io.install os.install strconv.install
encoding/base64.install: io.install os.install strconv.install
encoding/binary.install: io.install math.install os.install reflect.install
encoding/git85.install: bytes.install io.install os.install strconv.install
encoding/hex.install: os.install strconv.install strings.install
...
...
@@ -52,7 +52,7 @@ hash/adler32.install: hash.install os.install
hash/crc32.install: hash.install os.install
http.install: bufio.install bytes.install container/vector.install fmt.install io.install log.install net.install os.install path.install strconv.install strings.install utf8.install
image.install:
image/png.install: bufio.install compress/zlib.install hash
/crc32.install hash
.install image.install io.install os.install strconv.install
image/png.install: bufio.install compress/zlib.install hash
.install hash/crc32
.install image.install io.install os.install strconv.install
io.install: bytes.install os.install sort.install strings.install sync.install
json.install: bytes.install container/vector.install fmt.install math.install reflect.install strconv.install strings.install utf8.install
log.install: fmt.install io.install os.install runtime.install time.install
...
...
@@ -76,7 +76,7 @@ syscall.install: sync.install
tabwriter.install: bytes.install container/vector.install io.install os.install utf8.install
template.install: bytes.install container/vector.install fmt.install io.install os.install reflect.install runtime.install strings.install
testing.install: flag.install fmt.install os.install runtime.install utf8.install
testing/iotest.install:
bytes.install
io.install log.install os.install
testing/iotest.install: io.install log.install os.install
testing/quick.install: flag.install fmt.install math.install os.install rand.install reflect.install strings.install
testing/script.install: fmt.install os.install rand.install reflect.install strings.install
time.install: io.install once.install os.install syscall.install
...
...
src/pkg/bufio/bufio.go
View file @
02df7db8
...
...
@@ -8,6 +8,7 @@
package
bufio
import
(
"bytes"
;
"io"
;
"os"
;
"strconv"
;
...
...
@@ -193,17 +194,6 @@ func (b *Reader) ReadRune() (rune int, size int, err os.Error) {
return
rune
,
size
,
nil
;
}
// Helper function: look for byte c in array p,
// returning its index or -1.
func
findByte
(
p
[]
byte
,
c
byte
)
int
{
for
i
:=
0
;
i
<
len
(
p
);
i
++
{
if
p
[
i
]
==
c
{
return
i
}
}
return
-
1
;
}
// Buffered returns the number of bytes that can be read from the current buffer.
func
(
b
*
Reader
)
Buffered
()
int
{
return
b
.
w
-
b
.
r
}
...
...
@@ -219,7 +209,7 @@ func (b *Reader) Buffered() int { return b.w - b.r }
// ReadSlice returns err != nil if and only if line does not end in delim.
func
(
b
*
Reader
)
ReadSlice
(
delim
byte
)
(
line
[]
byte
,
err
os
.
Error
)
{
// Look in buffer.
if
i
:=
find
Byte
(
b
.
buf
[
b
.
r
:
b
.
w
],
delim
);
i
>=
0
{
if
i
:=
bytes
.
Index
Byte
(
b
.
buf
[
b
.
r
:
b
.
w
],
delim
);
i
>=
0
{
line1
:=
b
.
buf
[
b
.
r
:
b
.
r
+
i
+
1
];
b
.
r
+=
i
+
1
;
return
line1
,
nil
;
...
...
@@ -237,7 +227,7 @@ func (b *Reader) ReadSlice(delim byte) (line []byte, err os.Error) {
b
.
fill
();
// Search new part of buffer
if
i
:=
find
Byte
(
b
.
buf
[
n
:
b
.
w
],
delim
);
i
>=
0
{
if
i
:=
bytes
.
Index
Byte
(
b
.
buf
[
n
:
b
.
w
],
delim
);
i
>=
0
{
line
:=
b
.
buf
[
0
:
n
+
i
+
1
];
b
.
r
=
n
+
i
+
1
;
return
line
,
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