summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/text/internal/triegen/compact.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-03-24 23:31:34 -0700
committerenahum <nahumhbl@gmail.com>2017-03-25 03:31:34 -0300
commit54d3d47daf9190275bbdaf8703b84969a4593451 (patch)
tree05899b296d0186c1a0da8a540bc486e34ad8eec9 /vendor/golang.org/x/text/internal/triegen/compact.go
parent7460302dec7796e01c98264e84bece8169cb6ed9 (diff)
downloadchat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.gz
chat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.bz2
chat-54d3d47daf9190275bbdaf8703b84969a4593451.zip
PLT-6076 Adding viper libs for config file changes (#5871)
* Adding viper libs for config file changes * Removing the old fsnotify lib * updating some missing libs
Diffstat (limited to 'vendor/golang.org/x/text/internal/triegen/compact.go')
-rw-r--r--vendor/golang.org/x/text/internal/triegen/compact.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/golang.org/x/text/internal/triegen/compact.go b/vendor/golang.org/x/text/internal/triegen/compact.go
new file mode 100644
index 000000000..397b975c1
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/triegen/compact.go
@@ -0,0 +1,58 @@
+// Copyright 2014 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 triegen
+
+// This file defines Compacter and its implementations.
+
+import "io"
+
+// A Compacter generates an alternative, more space-efficient way to store a
+// trie value block. A trie value block holds all possible values for the last
+// byte of a UTF-8 encoded rune. Excluding ASCII characters, a trie value block
+// always has 64 values, as a UTF-8 encoding ends with a byte in [0x80, 0xC0).
+type Compacter interface {
+ // Size returns whether the Compacter could encode the given block as well
+ // as its size in case it can. len(v) is always 64.
+ Size(v []uint64) (sz int, ok bool)
+
+ // Store stores the block using the Compacter's compression method.
+ // It returns a handle with which the block can be retrieved.
+ // len(v) is always 64.
+ Store(v []uint64) uint32
+
+ // Print writes the data structures associated to the given store to w.
+ Print(w io.Writer) error
+
+ // Handler returns the name of a function that gets called during trie
+ // lookup for blocks generated by the Compacter. The function should be of
+ // the form func (n uint32, b byte) uint64, where n is the index returned by
+ // the Compacter's Store method and b is the last byte of the UTF-8
+ // encoding, where 0x80 <= b < 0xC0, for which to do the lookup in the
+ // block.
+ Handler() string
+}
+
+// simpleCompacter is the default Compacter used by builder. It implements a
+// normal trie block.
+type simpleCompacter builder
+
+func (b *simpleCompacter) Size([]uint64) (sz int, ok bool) {
+ return blockSize * b.ValueSize, true
+}
+
+func (b *simpleCompacter) Store(v []uint64) uint32 {
+ h := uint32(len(b.ValueBlocks) - blockOffset)
+ b.ValueBlocks = append(b.ValueBlocks, v)
+ return h
+}
+
+func (b *simpleCompacter) Print(io.Writer) error {
+ // Structures are printed in print.go.
+ return nil
+}
+
+func (b *simpleCompacter) Handler() string {
+ panic("Handler should be special-cased for this Compacter")
+}