Check-in [27ecac81d3]
Overview
Comment:Calculate the decompressed block length outside of the predictor loop
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:27ecac81d3f5ae4317a83f1f2825010857b6b288
User & Date: spaskalev on 2014-12-22 17:15:41
Other Links: manifest | tags
Context
2014-12-22
19:28
Extracted the predictor's hash function as a method of the context struct. Minor changes to the decompressor's variables. check-in: 9dfd3cb1a2 user: spaskalev tags: trunk
17:15
Calculate the decompressed block length outside of the predictor loop check-in: 27ecac81d3 user: spaskalev tags: trunk
16:41
Integrate the decompressor2 branch into trunk now that it is faster. check-in: 6d10a1d28f user: spaskalev tags: trunk
Changes

Modified src/0dev.org/predictor/predictor.go from [71e92568a2] to [46cd9d5cef].

169
170
171
172
173
174
175



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
		if rc < int(available) && err == nil {
			// Retry the read if we have fewer bytes than what the prediction header indicates
			var r int
			r, err = reader.Read(ctx.input[predicted+rc:])
			rc += r
			goto retryData
		} // Continue on any error, try to decompress and return it along the result




		// Walk the buffer, filling in the predicted blanks,
		// relocating read bytes and and updating the guess table
		for i, a := uint(0), predicted; i < 8; i++ {
			if (flags & (1 << i)) > 0 {
				// Guess succeeded, fill in from the table
				ctx.input[i] = ctx.table[ctx.hash]
				rc++
			} else {
				// Relocate a read byte
				ctx.input[i], a = ctx.input[a], a+1
				// Guess failed, update the table
				ctx.table[ctx.hash] = ctx.input[i]
			}
			// Update the hash
			ctx.hash = (ctx.hash << 4) ^ uint16(ctx.input[i])
		}

		// rc now contains the precise amount of populated data
		ctx.input = ctx.input[:rc]
		available = copy(output, ctx.input)

		total += available

		// Check for remaining bytes that dont fit in the output buffer
		if available < rc {







>
>
>



|
|


<










|







169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
		if rc < int(available) && err == nil {
			// Retry the read if we have fewer bytes than what the prediction header indicates
			var r int
			r, err = reader.Read(ctx.input[predicted+rc:])
			rc += r
			goto retryData
		} // Continue on any error, try to decompress and return it along the result

		// rc now contains the amount of actual bytes in this cycle (usually 8)
		rc += predicted

		// Walk the buffer, filling in the predicted blanks,
		// relocating read bytes and and updating the guess table
		for i, a := 0, predicted; i < rc; i++ {
			if (flags & (1 << uint(i))) > 0 {
				// Guess succeeded, fill in from the table
				ctx.input[i] = ctx.table[ctx.hash]

			} else {
				// Relocate a read byte
				ctx.input[i], a = ctx.input[a], a+1
				// Guess failed, update the table
				ctx.table[ctx.hash] = ctx.input[i]
			}
			// Update the hash
			ctx.hash = (ctx.hash << 4) ^ uint16(ctx.input[i])
		}

		// Copy the decompressed data to the output
		ctx.input = ctx.input[:rc]
		available = copy(output, ctx.input)

		total += available

		// Check for remaining bytes that dont fit in the output buffer
		if available < rc {