Merge pull request #10 from smith-30/feature/mod_add_dict

mod: add dict process
This commit is contained in:
smith30 2018-01-25 14:00:15 +09:00 committed by GitHub
commit 67b993939f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

10
conn.go
View File

@ -1169,19 +1169,21 @@ func (c *Conn) SetCompressionLevel(level int) error {
// AddTxDict adds payload to txDict.
func (c *Conn) AddTxDict(b []byte) {
c.txDict = append(b, c.txDict...)
c.txDict = append(c.txDict, b...)
if len(c.txDict) > maxWindowBits {
c.txDict = c.txDict[:maxWindowBits]
offset := len(c.txDict) - maxWindowBits
c.txDict = c.txDict[offset:]
}
}
// AddTxDict adds payload to rxDict.
func (c *Conn) AddRxDict(b []byte) {
c.rxDict = append(b, c.rxDict...)
c.rxDict = append(c.rxDict, b...)
if len(c.rxDict) > maxWindowBits {
c.rxDict = c.rxDict[:maxWindowBits]
offset := len(c.rxDict) - maxWindowBits
c.rxDict = c.rxDict[offset:]
}
}