mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 14:16:21 +00:00
511d6bfc54
* feat(share-links): Add protobuf and encode/decode url data methods * feat(new-links-format): Adds generators for new links format * feat: add parsing for new links format * feat: add messenger-level pubkey serialization and tests * feat: fix and test CreateCommunityURLWithChatKey * feat: impl and test parseCommunityURLWithChatKey * feat: fix and test CreateCommunityURLWithData * feat: impl and test parseCommunityURLWithData (not working) * feat: UrlDataResponse as response share urls api * feat: impl& tested ShareCommunityChannelURLWithChatKey * feat: impl & tested ParseCommunityChannelURLWithChatKey * fix: bring urls to new format * feat: add regexp for community channel urls * feat: impl & test contact urls with chatKey, Ens and data * fix: encodeDataURL/encodeDataURL patch from Samyoul * fix: fix unmarshalling protobufs * fix: fix minor issues, temporary comment TestParseUserURLWithENS * fix: allow url to contain extra `#` in the signature * fix: check signatures with SigToPub * chore: lint fixes * fix: encode the signature * feat: Check provided channelID is Uuid * fix(share-community-url): Remove if community encrypted scope * fix: review fixes * fix: use proto.Unmarshal instead of json.Marshal * feat(share-urls): Adds TagsIndices to community data * feat: support tag indices to community url data --------- Co-authored-by: Boris Melnik <borismelnik@status.im>
31 lines
839 B
Go
31 lines
839 B
Go
package brotli
|
|
|
|
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
Distributed under MIT license.
|
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
/* Functions for clustering similar histograms together. */
|
|
|
|
type histogramPair struct {
|
|
idx1 uint32
|
|
idx2 uint32
|
|
cost_combo float64
|
|
cost_diff float64
|
|
}
|
|
|
|
func histogramPairIsLess(p1 *histogramPair, p2 *histogramPair) bool {
|
|
if p1.cost_diff != p2.cost_diff {
|
|
return p1.cost_diff > p2.cost_diff
|
|
}
|
|
|
|
return (p1.idx2 - p1.idx1) > (p2.idx2 - p2.idx1)
|
|
}
|
|
|
|
/* Returns entropy reduction of the context map when we combine two clusters. */
|
|
func clusterCostDiff(size_a uint, size_b uint) float64 {
|
|
var size_c uint = size_a + size_b
|
|
return float64(size_a)*fastLog2(size_a) + float64(size_b)*fastLog2(size_b) - float64(size_c)*fastLog2(size_c)
|
|
}
|