// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package flate const ( // 2 bits: type 0 = literal 1=EOF 2=Match 3=Unused // 8 bits: xlength = length - MIN_MATCH_LENGTH // 22 bits xoffset = offset - MIN_OFFSET_SIZE, or literal lengthShift = 22; offsetMask = 1< pair into a match token. func matchToken(xlength uint32, xoffset uint32) token { return token(matchType + xlength<> lengthShift) } func lengthCode(len uint32) uint32 { return lengthCodes[len] } // Returns the offset code corresponding to a specific offset func offsetCode(off uint32) uint32 { const n = uint32(len(offsetCodes)); switch { case off < n: return offsetCodes[off] case off>>7 < n: return offsetCodes[off>>7] + 14 default: return offsetCodes[off>>14] + 28 } panic("unreachable"); }