Diff

Differences From Artifact [675059111f]:

To Artifact [dfe0b7b6cf]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main

import (
	pprof "0dev.org/debug/pprof"
	iou "0dev.org/ioutil"
	predictor "0dev.org/predictor"
	// "bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	var code int
................................................................................
	case len(os.Args) == 1:
		code = compress(os.Stdout, os.Stdin)
	case len(os.Args) == 2 && os.Args[1] == "-d":
		code = decompress(os.Stdout, os.Stdin)
	default:
		fmt.Fprintln(os.Stdout, "Usage: pdc [-d]")
	}

	pprof.Stop()

	os.Exit(code)
}

// Compress the data from the given io.Reader and write it to the given io.Writer
// I/O is buffered for better performance
func compress(output io.Writer, input io.Reader) int {
	var (
................................................................................
// Decompress the data from the given io.Reader and write it to the given io.Writer
// I/O is buffered for better performance
func decompress(output io.Writer, input io.Reader) int {
	var (
		err          error
		buffer       io.Writer = iou.SizedWriter(output, 4096)
		decompressor io.Reader = predictor.Decompressor(iou.SizedReader(input, 4096))
		//decompressor io.Reader = predictor.Decompressor(bufio.NewReader(input))
	)

	_, err = io.Copy(buffer, decompressor)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error while decompressing.\n", err)
		return 1
	}



<


<







 







<
<
<







 







<







1
2
3

4
5

6
7
8
9
10
11
12
..
14
15
16
17
18
19
20



21
22
23
24
25
26
27
..
56
57
58
59
60
61
62

63
64
65
66
67
68
69
package main

import (

	iou "0dev.org/ioutil"
	predictor "0dev.org/predictor"

	"fmt"
	"io"
	"os"
)

func main() {
	var code int
................................................................................
	case len(os.Args) == 1:
		code = compress(os.Stdout, os.Stdin)
	case len(os.Args) == 2 && os.Args[1] == "-d":
		code = decompress(os.Stdout, os.Stdin)
	default:
		fmt.Fprintln(os.Stdout, "Usage: pdc [-d]")
	}



	os.Exit(code)
}

// Compress the data from the given io.Reader and write it to the given io.Writer
// I/O is buffered for better performance
func compress(output io.Writer, input io.Reader) int {
	var (
................................................................................
// Decompress the data from the given io.Reader and write it to the given io.Writer
// I/O is buffered for better performance
func decompress(output io.Writer, input io.Reader) int {
	var (
		err          error
		buffer       io.Writer = iou.SizedWriter(output, 4096)
		decompressor io.Reader = predictor.Decompressor(iou.SizedReader(input, 4096))

	)

	_, err = io.Copy(buffer, decompressor)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error while decompressing.\n", err)
		return 1
	}