File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,13 @@ const (
32
32
line_length = 50
33
33
)
34
34
35
+ var (
36
+ space = []byte (" " )
37
+ doubleSpace = []byte (" " )
38
+ dot = []byte ("." )
39
+ newline = []byte ("\n " )
40
+ )
41
+
35
42
func XXD (r io.Reader , w io.Writer ) error {
36
43
line_offset := 0
37
44
@@ -54,31 +61,31 @@ func XXD(r io.Reader, w io.Writer) error {
54
61
w .Write (hexChar )
55
62
56
63
if i % 2 == 1 {
57
- io . WriteString ( w , " " )
64
+ w . Write ( space )
58
65
}
59
66
}
60
67
if n < len (buf ) {
61
68
for i := n ; i < len (buf ); i ++ {
62
- io . WriteString ( w , " " )
69
+ w . Write ( doubleSpace )
63
70
if i % 2 == 1 {
64
- io . WriteString ( w , " " )
71
+ w . Write ( space )
65
72
}
66
73
}
67
74
}
68
75
69
- io . WriteString ( w , " " )
76
+ w . Write ( space )
70
77
71
78
// Character values
72
79
b := buf [:n ]
73
80
for _ , c := range b {
74
81
if c > 0x1f && c < 0x7f {
75
82
io .WriteString (w , string (c ))
76
83
} else {
77
- io . WriteString ( w , "." )
84
+ w . Write ( dot )
78
85
}
79
86
}
80
87
81
- io . WriteString ( w , " \n " )
88
+ w . Write ( newline )
82
89
}
83
90
return nil
84
91
}
You can’t perform that action at this time.
0 commit comments