unipdf icon indicating copy to clipboard operation
unipdf copied to clipboard

Core: Refactor parser to use bufferedReadSeeker type

Open gunnsth opened this issue 5 years ago • 0 comments

Based on discussion in #441. The proposal is to create a buffered reader type which encapsulates a ReadSeeker and a buffered Reder (bufio.Reader). Rather than accessing and working with both separately.

The suggested type is something as follows:

// bufferedReadSeeker offers buffered read access to a seekable source (such as a file) with seek capabilities.
type bufferedReadSeeker struct {
rs io.ReadSeeker
reader *bufio.Reader
}
// Implement the Read and Seek methods.

The reason for using the bufio.Reader is purely based on performance during parsing as it has a buffer. Any time we change the offset position of rs a new reader must be constructed with a new buffer (and use the buffered information to correct for offsets as done in parser.GetPosition).

gunnsth avatar Apr 24 '19 18:04 gunnsth