Skip to content

Commit c2da369

Browse files
committed
extend 2M as buffer size (file size).
1 parent 20f9cc2 commit c2da369

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ reference
1515
.vscode
1616
debug
1717
test
18+
19+
go.sum

encoding.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ func Decode(dst, src []byte) (ndst int) {
8888
return
8989
}
9090

91-
//Decoder wrap decode for stream reader
91+
// Decoder wrap decode for stream reader
9292
type Decoder struct {
9393
wrapped io.Reader
94-
srcbuf [20480]byte
95-
dstbuf [20480]byte
94+
srcbuf [2048000]byte
95+
dstbuf [2048000]byte
9696
src []byte
9797
dst []byte
9898
//we did not record error, is that ok?
9999
}
100100

101101
const maxCharsOneLine = 72
102102

103-
//NewDecoder return Decoder which wrap Decode for stream reader
103+
// NewDecoder return Decoder which wrap Decode for stream reader
104104
func NewDecoder(r io.Reader) *Decoder {
105105
return &Decoder{wrapped: &eatLastNewLineReader{wrapped: newLineReader(r, maxCharsOneLine)}}
106106
}
@@ -138,7 +138,7 @@ func (d *Decoder) Read(p []byte) (nRead int, err error) {
138138
}
139139
}
140140

141-
//ReadRaw only read from wrapped io without Decoding
141+
// ReadRaw only read from wrapped io without Decoding
142142
func (d *Decoder) ReadRaw(p []byte) (nRead int, err error) {
143143
nRead, err = d.wrapped.Read(p)
144144
return
@@ -159,9 +159,9 @@ func (r *eatLastNewLineReader) Read(p []byte) (nRead int, err error) {
159159
return
160160
}
161161

162-
//numCharsLineReader Read
163-
//implement continue read if size of line eq numChars, until
164-
//size of line less than numChars
162+
// numCharsLineReader Read
163+
// implement continue read if size of line eq numChars, until
164+
// size of line less than numChars
165165
type numCharsLineReader struct {
166166
wrapped bufio.Reader
167167
numChars int //number of each line

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/corbamico/tbcload
2+
3+
go 1.21.3
4+
5+
require github.com/spf13/cobra v1.7.0
6+
7+
require (
8+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
9+
github.com/spf13/pflag v1.0.5 // indirect
10+
)

parser_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ func TestParser(t *testing.T) {
7575
}
7676

7777
func TestSingleFile(t *testing.T) {
78-
//sFile := "D:\\Program Files (x86)\\TclPro1.4\\win32-ix86\\bin\\simple.tbc"
79-
sFile := "c:\\Project\\go\\src\\github.com\\corbamico\\tbcload\\test\\aux1.tbc"
78+
sFile := "1.tbc"
8079
fs, err := os.Open(sFile)
8180
if err != nil {
8281
t.Error(err)

0 commit comments

Comments
 (0)