Implemented WriteTo which halves decompress times.

Added a drag race benchmark (for the fun of it)
This commit is contained in:
Caleb Gardner
2021-01-10 03:33:33 -06:00
parent ee9406513c
commit 76649fde7f
6 changed files with 221 additions and 59 deletions
+13 -2
View File
@@ -398,7 +398,18 @@ func (f *File) ExtractWithOptions(path string, dereferenceSymlink, unbreakSymlin
errs = append(errs, err)
return
} //Since we will be reading from the file
_, err = io.Copy(fil, f)
if f.Reader == nil && f.r != nil {
f.Reader, err = f.r.newFileReader(f.in)
if err != nil {
if verbose {
fmt.Println("Error while Copying data to:", path+"/"+f.name)
fmt.Println(err)
}
errs = append(errs, err)
return
}
}
_, err = io.Copy(fil, f.Reader)
if err != nil {
if verbose {
fmt.Println("Error while Copying data to:", path+"/"+f.name)
@@ -480,7 +491,7 @@ func (f *File) ExtractWithOptions(path string, dereferenceSymlink, unbreakSymlin
//Read from the file. Doesn't do anything fancy, just pases it to the underlying io.Reader. If a directory, return io.EOF.
func (f *File) Read(p []byte) (int, error) {
if f.IsDir() {
if !f.IsFile() {
return 0, io.EOF
}
var err error