Skip to content

Commit

Permalink
extend 2M as buffer size (file size).
Browse files Browse the repository at this point in the history
  • Loading branch information
corbamico committed Oct 14, 2023
1 parent 20f9cc2 commit c2da369
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ reference
.vscode
debug
test

go.sum
16 changes: 8 additions & 8 deletions encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ func Decode(dst, src []byte) (ndst int) {
return
}

//Decoder wrap decode for stream reader
// Decoder wrap decode for stream reader
type Decoder struct {
wrapped io.Reader
srcbuf [20480]byte
dstbuf [20480]byte
srcbuf [2048000]byte
dstbuf [2048000]byte
src []byte
dst []byte
//we did not record error, is that ok?
}

const maxCharsOneLine = 72

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

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

//numCharsLineReader Read
//implement continue read if size of line eq numChars, until
//size of line less than numChars
// numCharsLineReader Read
// implement continue read if size of line eq numChars, until
// size of line less than numChars
type numCharsLineReader struct {
wrapped bufio.Reader
numChars int //number of each line
Expand Down
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/corbamico/tbcload

go 1.21.3

require github.com/spf13/cobra v1.7.0

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
3 changes: 1 addition & 2 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func TestParser(t *testing.T) {
}

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

0 comments on commit c2da369

Please sign in to comment.