...
1
2
3
4 package s2
5
6 import "github.com/klauspost/compress/internal/race"
7
8 const hasAmd64Asm = true
9
10
11
12
13
14
15
16
17
18 func encodeBlock(dst, src []byte) (d int) {
19 race.ReadSlice(src)
20 race.WriteSlice(dst)
21
22 const (
23
24 limit12B = 16 << 10
25
26 limit10B = 4 << 10
27
28 limit8B = 512
29 )
30
31 if len(src) >= 4<<20 {
32 return encodeBlockAsm(dst, src)
33 }
34 if len(src) >= limit12B {
35 return encodeBlockAsm4MB(dst, src)
36 }
37 if len(src) >= limit10B {
38 return encodeBlockAsm12B(dst, src)
39 }
40 if len(src) >= limit8B {
41 return encodeBlockAsm10B(dst, src)
42 }
43 if len(src) < minNonLiteralBlockSize {
44 return 0
45 }
46 return encodeBlockAsm8B(dst, src)
47 }
48
49
50
51
52
53
54
55
56
57 func encodeBlockBetter(dst, src []byte) (d int) {
58 race.ReadSlice(src)
59 race.WriteSlice(dst)
60
61 const (
62
63 limit12B = 16 << 10
64
65 limit10B = 4 << 10
66
67 limit8B = 512
68 )
69
70 if len(src) > 4<<20 {
71 return encodeBetterBlockAsm(dst, src)
72 }
73 if len(src) >= limit12B {
74 return encodeBetterBlockAsm4MB(dst, src)
75 }
76 if len(src) >= limit10B {
77 return encodeBetterBlockAsm12B(dst, src)
78 }
79 if len(src) >= limit8B {
80 return encodeBetterBlockAsm10B(dst, src)
81 }
82 if len(src) < minNonLiteralBlockSize {
83 return 0
84 }
85 return encodeBetterBlockAsm8B(dst, src)
86 }
87
88
89
90
91
92
93
94
95
96 func encodeBlockSnappy(dst, src []byte) (d int) {
97 race.ReadSlice(src)
98 race.WriteSlice(dst)
99
100 const (
101
102 limit12B = 16 << 10
103
104 limit10B = 4 << 10
105
106 limit8B = 512
107 )
108 if len(src) >= 64<<10 {
109 return encodeSnappyBlockAsm(dst, src)
110 }
111 if len(src) >= limit12B {
112 return encodeSnappyBlockAsm64K(dst, src)
113 }
114 if len(src) >= limit10B {
115 return encodeSnappyBlockAsm12B(dst, src)
116 }
117 if len(src) >= limit8B {
118 return encodeSnappyBlockAsm10B(dst, src)
119 }
120 if len(src) < minNonLiteralBlockSize {
121 return 0
122 }
123 return encodeSnappyBlockAsm8B(dst, src)
124 }
125
126
127
128
129
130
131
132
133
134 func encodeBlockBetterSnappy(dst, src []byte) (d int) {
135 race.ReadSlice(src)
136 race.WriteSlice(dst)
137
138 const (
139
140 limit12B = 16 << 10
141
142 limit10B = 4 << 10
143
144 limit8B = 512
145 )
146 if len(src) >= 64<<10 {
147 return encodeSnappyBetterBlockAsm(dst, src)
148 }
149 if len(src) >= limit12B {
150 return encodeSnappyBetterBlockAsm64K(dst, src)
151 }
152 if len(src) >= limit10B {
153 return encodeSnappyBetterBlockAsm12B(dst, src)
154 }
155 if len(src) >= limit8B {
156 return encodeSnappyBetterBlockAsm10B(dst, src)
157 }
158 if len(src) < minNonLiteralBlockSize {
159 return 0
160 }
161 return encodeSnappyBetterBlockAsm8B(dst, src)
162 }
163
View as plain text