20
0

Seek if reading the file contents is not entirely necessary

This commit is contained in:
Nikhil Bhargava 2018-07-06 19:58:23 -04:00
parent d1d6f84447
commit 46b1dcb078

View File

@ -211,15 +211,13 @@ func (w *WorkBook) get_string(buf io.ReadSeeker, size uint16) (res string, err e
res = string(runes) res = string(runes)
} }
if richtext_num > 0 { if richtext_num > 0 {
var bts []byte
var seek_size int64 var seek_size int64
if w.Is5ver { if w.Is5ver {
seek_size = int64(2 * richtext_num) seek_size = int64(2 * richtext_num)
} else { } else {
seek_size = int64(4 * richtext_num) seek_size = int64(4 * richtext_num)
} }
bts = make([]byte, seek_size) _, err = buf.Seek(seek_size, io.SeekCurrent)
err = binary.Read(buf, binary.LittleEndian, bts)
if err == io.EOF { if err == io.EOF {
w.continue_rich = richtext_num w.continue_rich = richtext_num
} }
@ -227,9 +225,7 @@ func (w *WorkBook) get_string(buf io.ReadSeeker, size uint16) (res string, err e
// err = binary.Read(buf, binary.LittleEndian, bts) // err = binary.Read(buf, binary.LittleEndian, bts)
} }
if phonetic_size > 0 { if phonetic_size > 0 {
var bts []byte _, err = buf.Seek(int64(phonetic_size), io.SeekCurrent)
bts = make([]byte, phonetic_size)
err = binary.Read(buf, binary.LittleEndian, bts)
if err == io.EOF { if err == io.EOF {
w.continue_apsb = phonetic_size w.continue_apsb = phonetic_size
} }