mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 20:27:03 +01:00
684b7a999f
* Dump: Use mholt/archive/v3 to support tar including many compressions Signed-off-by: Philipp Homann <homann.philipp@googlemail.com> * Dump: Allow dump output to stdout Signed-off-by: Philipp Homann <homann.philipp@googlemail.com> * Dump: Fixed bug present since #6677 where SessionConfig.Provider is never "file" Signed-off-by: Philipp Homann <homann.philipp@googlemail.com> * Dump: never pack RepoRootPath, LFS.ContentPath and LogRootPath when they are below AppDataPath Signed-off-by: Philipp Homann <homann.philipp@googlemail.com> * Dump: also dump LFS (fixes #10058) Signed-off-by: Philipp Homann <homann.philipp@googlemail.com> * Dump: never dump CustomPath if CustomPath is a subdir of or equal to AppDataPath (fixes #10365) Signed-off-by: Philipp Homann <homann.philipp@googlemail.com> * Use log.Info instead of fmt.Fprintf Signed-off-by: Philipp Homann <homann.philipp@googlemail.com> * import ordering * make fmt Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Matti R <matti@mdranta.net>
53 lines
1.5 KiB
Go
Vendored
53 lines
1.5 KiB
Go
Vendored
// Copyright 2014-2017 Ulrich Kunitz. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package lzma
|
|
|
|
// movebits defines the number of bits used for the updates of probability
|
|
// values.
|
|
const movebits = 5
|
|
|
|
// probbits defines the number of bits of a probability value.
|
|
const probbits = 11
|
|
|
|
// probInit defines 0.5 as initial value for prob values.
|
|
const probInit prob = 1 << (probbits - 1)
|
|
|
|
// Type prob represents probabilities. The type can also be used to encode and
|
|
// decode single bits.
|
|
type prob uint16
|
|
|
|
// Dec decreases the probability. The decrease is proportional to the
|
|
// probability value.
|
|
func (p *prob) dec() {
|
|
*p -= *p >> movebits
|
|
}
|
|
|
|
// Inc increases the probability. The Increase is proportional to the
|
|
// difference of 1 and the probability value.
|
|
func (p *prob) inc() {
|
|
*p += ((1 << probbits) - *p) >> movebits
|
|
}
|
|
|
|
// Computes the new bound for a given range using the probability value.
|
|
func (p prob) bound(r uint32) uint32 {
|
|
return (r >> probbits) * uint32(p)
|
|
}
|
|
|
|
// Bits returns 1. One is the number of bits that can be encoded or decoded
|
|
// with a single prob value.
|
|
func (p prob) Bits() int {
|
|
return 1
|
|
}
|
|
|
|
// Encode encodes the least-significant bit of v. Note that the p value will be
|
|
// changed.
|
|
func (p *prob) Encode(e *rangeEncoder, v uint32) error {
|
|
return e.EncodeBit(v, p)
|
|
}
|
|
|
|
// Decode decodes a single bit. Note that the p value will change.
|
|
func (p *prob) Decode(d *rangeDecoder) (v uint32, err error) {
|
|
return d.DecodeBit(p)
|
|
}
|